cURL / Mailing Lists / curl-library / Single Mail


Digest auth, POST and Transfer-Encodeing: chunked

From: <>
Date: Fri, 23 Oct 2009 11:39:31 +0100


Trying to use digest auth on a post request with chunked transfer-encoding,
I get a timeout. It looks like libcurl puts the transfer-encoding header on
the initial empty request, but doesn't put anything in the body so the
server just sits there waiting. I think an empty request with chunked
transfer encoding would need to send a marker to indicate the data is

The code below reproduces the issue (I did it on Windows/VC++ - I've tried
to make it so it should work with C and on other platforms, but it might
need tweaking). If you comment out curl_easy_setopt(curl,
CURLOPT_HTTPHEADER, header); the request works.

Many thanks,

The VERBOSE output is:

* About to connect() to localhost port 3435 (#0)
* Trying * connected
* Connected to localhost ( port 3435 (#0)
* Server auth using Digest with user 'testuser'
> POST /example HTTP/1.1
Host: localhost:3435
Accept: */*
Transfer-Encoding: chunked
Content-Type: application/x-www-form-urlencoded

* Operation timed out after 30000 milliseconds with 0 bytes received
* Closing connection #0
* Timeout was reached

#include <curl/curl.h>
#include <io.h>
#include <fcntl.h>

//fill these in
const char* url = "";
const char* file = "";
const char* userpwd = "";

static size_t read_callback(void *ptr, size_t size, size_t nmemb, void
  size_t retcode;
  intptr_t fd = (intptr_t)stream;
  retcode = read(fd, ptr, size * nmemb);
  return retcode;

int main(int argc, char argv[])
struct curl_slist *header;
CURLcode res;
CURL* curl;
intptr_t hd;

curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30);
header = NULL;
header = curl_slist_append(header, "Transfer-Encoding: chunked");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header);
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_easy_setopt(curl, CURLOPT_USERPWD, userpwd);
curl_easy_setopt(curl, CURLOPT_POST, 1);
hd = _open(file, _O_RDONLY);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
curl_easy_setopt(curl, CURLOPT_READDATA, (void*)hd);
res = curl_easy_perform(curl);
return 0;

List admin:
Received on 2009-10-23