To circle back around and share on CodePlex William shared with me a code snippet and his test server and we figured out the problem.
I noticed that there isn’t a Content-Length header and Transfer-Encoding: chunked is being used instead to deliver the message body. Next I took a look at your code provided and made a couple of tweaks printing out the whole response message and checking for
the existence of the Content-Length header. Here is the code I used:
// Make the request and asynchronously process the response.
auto response = client.request(methods::GET).get();
wprintf(L"Has Content-Length header.\n");
wprintf(L"Missing Content-Length header.\n");
Running this gives the following output:
MSG:HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Date: Sat, 18 Jan 2014 00:25:24 GMT
Missing Content-Length header.
What is going on is the http_headers::content_length() method will return 0 if there isn’t actually a Content-Length header field present. This was confusing you and leading you to think there was no actual body data, when in fact there was. I think this behavior
isn’t idea, but I’m not sure of a better solution. The other option is we could have it throw an exception if the Content-Length header doesn’t exist, but I’m not sure that is so great. If you care about the presence of a specific header it probably best to
check with the http_headers::has(…) method.
Please note as well if you don’t care about knowing the actual underlying length of the data you can always just directly read from the response stream until the end is reached or use one of the http_response::extract_* helper methods like extract_string().
In all cases you will always get the data from the body regardless of the method transferred.