[mod_python] 411 Length Required for POST

John Ruff jcruff at gmail.com
Fri Mar 3 14:45:54 EST 2006

Here's the javascript code for setting up the XMLHttpRequest.  *Note:  
This is not production code.

function getLogData() {
     /* Create a new XMLHttpRequest object to talk to the Web server */
     /*@cc_on @*/
     /*@if (@_jscript_version >= 5)
     try {
       xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
       try {
         xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (e2) {
         xmlHttp = false;
     @end @*/

     if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
       xmlHttp = new XMLHttpRequest();

     xmlHttp.onreadystatechange = handleHttpResponse;
     xmlHttp.open("POST", url, true);
     xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form- 
     xmlHttp.setRequestHeader('Content-length', '0');

And here's the header information:

POST /python/adodb/pixfifo/get HTTP/1.1
Host: localhost:8880
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv: 
1.8) Gecko/20051204 Firefox/1.5
Accept: text/xml,application/xml,application/xhtml+xml,text/ 
Accept-Language: en-us,en;q=0.5
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/x-www-form-urlencoded
Pragma: no-cache
Cache-Control: no-cache

HTTP/1.x 411 Length Required
Date: Fri, 03 Mar 2006 19:41:27 GMT
Server: Apache/2.0.55 (Unix) DAV/2 mod_python/3.2.7 Python/2.3.5 PHP/ 
5.1.2 mod_ssl/2.0.55 OpenSSL/0.9.8a
Content-Length: 390
Connection: close
Content-Type: text/html; charset=iso-8859-1

Thanks for reviewing.
John Ruff
jcruff at gmail.com

"No one can see past a choice they don't understand." --The Oracle

On Mar 3, 2006, at 2:14 PM, Deron Meranda wrote:

> On 3/3/06, John Ruff <jcruff at gmail.com> wrote:
>> Thanks, actually I'm already using x-www-form-urlencoded originally
>> as a test to confirm the header was being set with XMLHtttpRequest's
>> setRequestHeader() method (which is it).  But for whatever reason the
>> Content-Length is not being set in the POST header.
> Are you actually sending any content?
> POST requests should almost always be sent with multipart/form-data.
> What browser/user agent are you using?  Can you include a
> (short) snippet of your javascript code where you are setting up
> can calling the XMLHttpRequest object.
> --
> Deron Meranda

More information about the Mod_python mailing list