0 Replies Latest reply on Oct 25, 2007 2:03 AM by neil667

    HTTPService POST with XML does not declare charset encoding

    neil667
      Hi all.

      I'm trying to do a HTTP POST of some XML using HTTPService and I've got it working apart form the fact that the HTTP message sent does no declare what charcater set it is using for encoding.

      As a test I send a 'ñ' character and it seems from the resultant bytes that the charset being used is UTF-8.

      My ActionScript is...

      var xml:XML=new XML(<root/>);
      xml.@testCharacter="ñ";
      xml.appendChild(<login/>);
      xml.login.@username="bob";
      xml.login.@password="secret";
      var httpService:HTTPService=new HTTPService();
      httpService.url=' http://app.localhost/null';
      httpService.method="POST";
      httpService.contentType=HTTPService.CONTENT_TYPE_XML;
      httpService.request=xml;
      httpService.send();

      And what seems to get sent over the wire is (shown in 8bit-ASCII)...

      POST /null HTTP/1.1
      Host: app.localhost
      User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7
      Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png ,*/*;q=0.5
      Accept-Language: en,en-us;q=0.7,en-gb;q=0.3
      Accept-Encoding: gzip,deflate
      Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
      Keep-Alive: 300
      Connection: keep-alive
      Content-type: application/xml
      Content-length: 77

      <root testCharacter="A±">
      <login username="bob" password="secret"/>
      </root>

      Anyone know (1) how I can control what character set gets used for encoding and (2) how I can get either XML or HTTPService to declare what the encoding is?

      Thanks in advance, Neil.