Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #15582

Re: XMLHttpRequest: POST with Data

From Christoph Becker <cmbecker69@gmx.de>
Newsgroups comp.lang.javascript
Subject Re: XMLHttpRequest: POST with Data
Date 2012-08-26 23:42 +0200
Organization Aioe.org NNTP Server
Message-ID <k1e57q$gj0$1@speranza.aioe.org> (permalink)
References (2 earlier) <4919648.gLsDIqzOUs@PointedEars.de> <k1af83$q69$1@speranza.aioe.org> <2094311.UPhlsrQmMF@PointedEars.de> <k1d9g5$2jn$2@speranza.aioe.org> <7781613.3ztUY42lFh@PointedEars.de>

Show all headers | View raw


Thomas 'PointedEars' Lahn wrote:
> Christoph Becker wrote:
> 
>> Thomas 'PointedEars' Lahn wrote:
>>> Per section 4.3, RFC 2616 (HTTP/1.1) mandates that the message body must
>>> contain only ASCII octets.
>>
>> I was not able to find the restriction on ASCII. RFC2616, section 7.2
>> mandates, that the entity-body has to contain OCTETs, where OCTET is
>> defined in section 2.2 as "any 8-bit sequence of data".
> 
> I stand corrected.  However, section 19.3 alludes [1] to what is known as 
> the "be conservative in what you do, liberal in what to accept from others" 
> paradigm of the Internet ("Postel's law") [2].  Not knowing over which lines 
> the HTTP message will be transmitted, and what the capabilities of the 
> involved software are, it appears to be prudent to choose (the characters 
> in) US-ASCII as the lowest common denominator.

ACK

> When discussing character encoding, it should also be mentioned that not 
> even choosing a specific Unicode encoding such as UTF-8 ensures 
> compatibility.  The Macintosh operating system is known to use the more 
> versatile, but in terms of memory footprint more expensive, character 
> composition feature of Unicode, while other systems tend not to; as a 
> result, the same character may be encoded using the same Unicode encoding in 
> a different way and may need to be normalized in order to be compatible) 
> [3].  This applies in particular to a Content Management System where some 
> authors might use a Macintosh computer, while other authors and most 
> visitors would not.

Thanks for this information -- that comes in handy.

> It should be investigated whether this applies to the 
> implementations of the encodeURI() and encodeURIComponent() methods as well; 
> ECMAScript, 5.1 Edition [4], do not mandate normalization before percent-
> encoding. (I have developed a novel approach [5] that is applicable to the
> ECMAScript Support Matrix [6] and similar kinds of research, and is going to 
> help there.)

I took only a quick look at the "ECMAScript Support Matrix", but I
consider it a remarkable and valuable work.  I'll have a closer look at
it, and if my time and my abilities permit, I'll try to contribute.

>> So for POST requests, when the Content-Type is text/plain (e.g. by using
>> <form enctype="text/plain">) even non-ASCII characters in the body can be
>> sent directly. But not all server side "languages" will handle this (e.g.
>> PHP will not fill in the $_POST variable).
> 
> PHP is not supposed to fill the $_POST array then; there are no parameters.  
> Indeed, apparently there is no trivial way, if any, to retrieve the message 
> body with PHP then; at least the input does not show up anywhere in 
> phpinfo().
> 
>> So it seems this is the reason, why one should use Content-Type
>> application/x-www-form-urlencoded, which requires percent-
>> encoding of the request body.
> 
> I do not think so.  Instead, in addition to the reason I mentioned above, 
> enctype="text/plain" is not mentioned in HTML 4.01 (but not forbidden by it 
> either) [7], so it is unsurprising that some server-side applications with a 
> longer development history would not support it.

As Stefan mentioned in another branch of this thread, there is a way for
PHP to access the body of the POST request via standard input.  Making
available the body of the request was already defined for CGI/1.1
<http://tools.ietf.org/html/draft-robinson-www-interface-00> (section
8), so the body *might* be generally available for server-side
applications, even if they are not implemented as CGI/1.1 applications
(like mod_php).

That's not to argue, that "application/x-www-form-urlencoded" is most
probably the safest and most convenient Content-Type for POST requests.

> Incidentally, the current HTML5 Working Draft places more constraints there, 
> specifying "text/plain" as one of only three media types that are to be 
> supported there. [8]  So apparently there are some, probably newer, server-
> side applications that support it.

-- 
Christoph M. Becker

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

XMLHttpRequest: POST with Data Gene Wirchenko <genew@ocis.net> - 2012-08-23 15:00 -0700
  Re: XMLHttpRequest: POST with Data "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-08-23 22:48 +0000
    Re: XMLHttpRequest: POST with Data Gene Wirchenko <genew@ocis.net> - 2012-08-23 16:40 -0700
      Re: XMLHttpRequest: POST with Data "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-08-26 20:39 +0000
  Re: XMLHttpRequest: POST with Data Christoph Becker <cmbecker69@gmx.de> - 2012-08-24 01:11 +0200
    Re: XMLHttpRequest: POST with Data Gene Wirchenko <genew@ocis.net> - 2012-08-23 16:42 -0700
      Re: XMLHttpRequest: POST with Data Christoph Becker <cmbecker69@gmx.de> - 2012-08-24 02:54 +0200
        Re: XMLHttpRequest: POST with Data Gene Wirchenko <genew@ocis.net> - 2012-08-23 19:04 -0700
          Re: XMLHttpRequest: POST with Data Tim Streater <timstreater@greenbee.net> - 2012-08-24 08:57 +0100
    Re: XMLHttpRequest: POST with Data Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-08-25 12:02 +0200
      Re: XMLHttpRequest: POST with Data Christoph Becker <cmbecker69@gmx.de> - 2012-08-25 14:09 +0200
        Re: XMLHttpRequest: POST with Data Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-08-25 15:20 +0200
          Re: XMLHttpRequest: POST with Data Christoph Becker <cmbecker69@gmx.de> - 2012-08-26 15:49 +0200
            Re: XMLHttpRequest: POST with Data Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-08-26 19:15 +0200
              Re: XMLHttpRequest: POST with Data Stefan Weiss <krewecherl@gmail.com> - 2012-08-26 19:54 +0200
                Re: XMLHttpRequest: POST with Data Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-08-26 21:43 +0200
              Re: XMLHttpRequest: POST with Data Christoph Becker <cmbecker69@gmx.de> - 2012-08-26 23:42 +0200
  Re: XMLHttpRequest: POST with Data Denis McMahon <denismfmcmahon@gmail.com> - 2012-08-24 02:55 +0000
  Re: XMLHttpRequest: POST with Data "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-08-23 19:28 -0700
  Re: XMLHttpRequest: POST with Data "Tom de Neef" <tdeneef@qolor.nl> - 2012-08-24 15:58 +0200
  Re: XMLHttpRequest: POST with Data Ross McKay <au.org.zeta.at.rosko@invalid.invalid> - 2012-08-26 08:38 +1000
  Re: XMLHttpRequest: POST with Data Mike Winter <usenet@michael-winter.me.invalid> - 2012-08-26 14:59 +0100

csiph-web