cURL / Mailing Lists / curl-library / Single Mail

curl-library

PUT of empty file with multi-pass authentication fails

From: Jonathan Brown <jwbrown_at_adobe.com>
Date: Mon, 19 Mar 2012 18:03:12 -0700

I'm using libcurl 7.24.0 to upload files to a server. The request hangs (or times out) if I try to PUT an empty file. I've set CURLOPT_HTTPAUTH to CURLAUTH_ANY and supplied a CURLOPT_USERPWD. Server auth using Digest succeeds for CURLOPT_INFILESIZE_LARGE > 0.

From what I can tell the problem occurs because, when the file size is 0 bytes, this test in http_perhapsrewind() fails (expectsend == bytessent == 0):

        if((expectsend == -1) || (expectsend > bytessent)) {
            ...
            conn->bits.close = TRUE;
            data->req.size = 0; /* don't download any more than 0 bytes */
            ...
        }

Thus in Curl_http_readwrite_headers(), these tests fail:

        if(0 == k->maxdownload)
          *stop_reading = TRUE;

        if(*stop_reading) {
          /* we make sure that this socket isn't read more now */
          k->keepon &= ~KEEP_RECV;
        }

And so, in Curl_readwrite(), *done is never set to TRUE:

  *done = (0 == (k->keepon&(KEEP_RECV|KEEP_SEND|
                            KEEP_RECV_PAUSE|KEEP_SEND_PAUSE))) ? TRUE : FALSE;

Adding a CURLOPT_IOCTLFUNCTION has no effect; it is never called in this case.

Is this behavior a bug? Or is there some option or hook that I am missing?

Thanks.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-03-20