[Mapserver-dev] HTTP Post Handling

Frank Warmerdam warmerdam at pobox.com
Fri Feb 13 10:21:02 EST 2004


Rob Atkinson wrote:
> 
> The relevant RFC states that:
> 
> /For compatibility with HTTP/1.0 applications, HTTP/1.1 requests 
> containing a message-body MUST include a valid Content-Length header 
> field unless the server is known to be HTTP/1.1 compliant. If a request 
> contains a message-body and a Content-Length is not given, the server 
> SHOULD respond with 400 (bad request) if it cannot determine the length 
> of the message, or with 411 (length required) if it wishes to insist on 
> receiving a valid Content-Length.
> /
> IMHO, this means that if mapserv is served by a HTTP 1.1 compliant 
> server there is no requirement for the client to set the Content-Length 
> and thus thus code in cgiutils.c :
> 
>    cl = atoi(getenv("CONTENT_LENGTH"));
> 
>     if(strcmp(request->contenttype, "application/x-www-form-urlencoded")) {
>      
>       request->postrequest = (char *)malloc(sizeof(char)*cl+1);
>       if (fread(request->postrequest, 1, cl, stdin) < cl){
>         printf("Content-type: text/html%c%c",10,10);
>         printf("POST body is short\n");
>         exit(1);
>       }
>  
> is at fault. At the very least it should throw a 411 exception, but it 
> would be better to make it more robust.

Rob,

There is no excuse for us not to just read the data dynamically if there
is no Content-Length.  I have done this in a number of other web services.
I would suggest you file it as a bug in bugzilla.  If no one else will fix
it then I will, but it would be helpful to have a test case I could easily
use to test it.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the mapserver-dev mailing list