cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Libcurl request generating HTTP/1.1 411 Length Required error

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Thu, 18 Dec 2003 13:29:15 +0100 (CET)

On Wed, 17 Dec 2003, Jacob Swed wrote:

> The library version being used is 7.11.0-20031217. Compiled under OS X
> 10.2.8 with --disable-ipv6.
>
> When curl issues a PUT (or other custom header the pushes data) is not
> including the "Content-Length" header initially.

That's a bug indeed.

> This causes a HTTP 411 Length Required error to be returned by the server.
> With our users it seems to be a problem with IIS 6.0 on Windows 2003. On
> Windows 2000, IIS 5.0 responds with a challenge request and when the
> properly authenticated request (e.g. PUT) is reissued it does contain the
> "Content-Length" header and succeeds as expected.

Aha, ok. You want some kind of authentication to take place and then a PUT to
be issued?

I've never quite understood what request to use during the authentication
phase (for non-GET requests), but I take it these servers want a GET until it
is done and then the PUT should be issued... I guess we need to read up on
what the spec says. The Digest authentication uses the request keyword in the
hash, so the question is what keyword to use there before the autentication is
done...

> We do not have enough knowledge of curl to propose a fix we are sure would
> not break something else. But, we suspect these lines in http.c introduce
> the problem:
>
> if(!authdone)
> /* until the auth is done, pretend we only do GET */
> httpreq = HTTPREQ_GET;
> else
> httpreq = data->set.httpreq;
>
> This will cause the default case to be hit in the switch statement that
> follows and since that case treats the request like a GET the header is
> obviously not set.

Correct, since it can't perform a true PUT until autentication is done so it
needs to "fake" a GET until then. Hence this code.

-- 
    Daniel Stenberg -- http://curl.haxx.se/ -- http://daniel.haxx.se/
   [[ Do not send mails to this email address. They won't reach me. ]]
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
Received on 2003-12-18