Hi,
I'm trying to build an application that consumes a rest server
(MongoDB). The server authentication method is based on Digest access
authentication (
http://en.wikipedia.org/wiki/
Digest_access_authentication).
This means that authentication information must be set in the
'Authorization' field of the request's header. In order to do that, I
need to perform a first request that fails (401 error), grab some info
from the response like 'realm', 'nonce' and 'qop' values from the 'WWW-
Authenticate' header field.
With these information, I can then build a valid digest authentication
header with my credentials and then send a second request that will
succeed.
My issue is that I can't access the header fields nor the body from
the first response because has soon as I try to access them, cpp-
netlib throw an exception with the message 'Invalid status part'.
When I activate cpp-netlib debug outputs (with BOOST_NETWORK_DEBUG), I
can see the date I'm interested in being dumped to the console:
[DEBUG c:\dev\cpp_default\lib\cpp-netlib\boost\network\protocol\http
\client\connection\async_protocol_handler.hpp:176]: [parser:10] buffer
contents: "401\r\nWWW-Authenticate: Digest realm="mongo", nonce="xxx",
algorithm=MD5, qop="auth" \r\nContent-Type: text/plain\r\nConnection:
close\r\nContent-Length: 12\r\n\r\nnot allowed\n"
How can I access them without causing an exception?
Thank you
Note: I'm using the latest cpp-netlib (0.9.4) with VC++ 10 and boost
1.47.