Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #15556
| Message-ID | <2094311.UPhlsrQmMF@PointedEars.de> (permalink) |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2012-08-25 15:20 +0200 |
| Subject | Re: XMLHttpRequest: POST with Data |
| Newsgroups | comp.lang.javascript |
| References | <429d38h112ptste9sp22ks8sqk9cgumo7r@4ax.com> <k16d9n$tqa$1@speranza.aioe.org> <4919648.gLsDIqzOUs@PointedEars.de> <k1af83$q69$1@speranza.aioe.org> |
| Followup-To | comp.lang.javascript |
Followups directed to: comp.lang.javascript
Christoph Becker wrote:
> Thomas 'PointedEars' Lahn wrote:
>> Christoph Becker wrote:
>>> For POST requests escaping on the client side should not be necessary.
>> Incorrect. The payload of the POST request (the message body) needs to
>> be URI-percent-encoded, see RFC 2616.
>
> Thanks for correcting me. I was not aware of this, as in the past I
> always used jQuery to send Ajax POST requests, and the respective jQuery
> methods obscure this fact by doing the encoding behind the scenes,
> what's AFAIK not documented.
To be precise (I have had time to re-read the RFC), URI-percent-encoding is
not mandatory. But if the payload contains ASCII characters, a form of
encoding that results in ASCII octets is.
Per section 4.3, RFC 2616 (HTTP/1.1) mandates that the message body must
contain only ASCII octets. This is easily accomplished in a symmetrical way
with percent-encoding as defined in RFC 3986 ("Uniform Resource
Identifiers"), section 2.1. (In ECMAScript implementations this is
implemented as the encodeURIComponent() function.)
The message body may also, instead, be encoded using the specified Transfer-
Encoding, the default of which is `identity' (no special encoding; see
section 14.41). Other Transfer-Encodings specified there already include
the common `gzip', but AIUI as long as both client and server support it,
any transfer encoding that results in an ASCII-only message body may be
used.
It is possible that a browser API would apply a suitable encoding before
transmitting the HTTP request message if it encountered non-ASCII characters
in the payload. However, that is nothing that should be relied upon.
The possibility of sending the payload gzipped instead of percent-encoded if
the server supports it certainly should be investigated further. This would
make sense if the amount of client-side script code required for gzipping
were less than the amount of data saved in the payload when switching from
percent-encoding to gzipping. On the other hand, it might be a good idea if
browser APIs would use gzip transparently if supported by the server and
deemed reasonable; previous gzipping by scripts would be of double
disadvantage then.
Ceterum censeo jQuery esse delendam.
PointedEars
--
When all you know is jQuery, every problem looks $(olvable).
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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