Update: I found out about winhttptracecfg.exe, here's my tracelog. As you
can see, the second call to WinHttpSetCredentials fails.
Thanks,
Peter Beardsley
Engineer, Loftware Inc.
------------------------------START LOG------------------------------
11:03:27.448 ::*Session* :: >>>> WinHttp Version 5.1 Build 5.1.2600 Aug 3
2004 22:24:11>>>>Process WebListen_WinHttp.exe [5120 (0x1400)] started at
11:03:27.448 05/01/2006
11:03:32.120 ::*Session* :: WinHttpOpen("WebListen", (0), "", "", 0x0)
11:03:32.120 ::*Session* :: WinHttpOpen() returning handle 0x13a3000
11:03:32.214 ::*Session* ::
WinHttpCrackUrl("http://host:8080/path/to/servlet", 0x0, 0x0, 0x14cfd18)
11:03:32.214 ::*Session* ::
WinHttpCrackUrlA("http://host:8080/path/to/servlet", 0x41, 0x0, 0x14cf348)
11:03:32.214 ::*Session* :: WinHttpCrackUrlA() returning TRUE
11:03:32.214 ::*Session* :: WinHttpCrackUrl() returning TRUE
11:03:32.214 ::*Session* :: WinHttpConnect(0x13a3000, "pbeardsley-xp", 8080,
0x0)
11:03:32.229 ::*Session* :: WinHttpConnect() returning handle 0x1553000
11:03:32.229 ::*Session* :: WinHttpOpenRequest(0x1553000, "POST",
"/path/to/servlet", "", "", 0x0, 0x00000100)
11:03:32.229 ::*Session* :: WinHttpCreateUrlA(0x14cf228, 0x0, 0x15d0000,
0x14cf264)
11:03:32.229 ::*Session* :: WinHttpCreateUrlA() returning TRUE
11:03:32.229 ::*0000001* :: WinHttpOpenRequest() returning handle 0x15c0000
11:03:32.229 ::*0000001* :: WinHttpSendRequest(0x15c0000, "", 0, 0xf5bf00,
51, 51, 0)
11:03:32.245 ::*0000001* :: "pbeardsley-xp" resolved
11:03:32.292 ::*0000001* :: sending data:
11:03:32.292 ::*0000001* :: 245 (0xf5) bytes
11:03:32.292 ::*0000001* :: <<<<-------- HTTP stream follows below
----------------------------------------------->>>>
11:03:32.292 ::*0000001* :: POST /path/to/servlet HTTP/1.1
11:03:32.292 ::*0000001* :: User-Agent: WebListen
11:03:32.292 ::*0000001* :: Host: host:8080
11:03:32.292 ::*0000001* :: Content-Length: 51
11:03:32.292 ::*0000001* :: Connection: Keep-Alive
11:03:32.292 ::*0000001* :: Cache-Control: no-cache
11:03:32.292 ::*0000001* :: Pragma: no-cache
11:03:32.292 ::*0000001* ::
11:03:32.292 ::*0000001* :: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
11:03:32.292 ::*0000001* :: <<<<-------- End
----------------------------------------------->>>>
11:03:32.292 ::*0000001* :: WinHttpSendRequest() returning TRUE
11:03:32.292 ::*0000001* :: WinHttpReceiveResponse(0x15c0000, 0x0)
11:03:32.308 ::*0000001* :: received data:
11:03:32.308 ::*0000001* :: 1024 (0x400) bytes
11:03:32.308 ::*0000001* :: <<<<-------- HTTP stream follows below
----------------------------------------------->>>>
11:03:32.308 ::*0000001* :: HTTP/1.1 401 Unauthorized
11:03:32.308 ::*0000001* :: Server: Apache-Coyote/1.1
11:03:32.308 ::*0000001* :: WWW-Authenticate: Digest realm="realm",
qop="auth", nonce="e69940d4976c0a1de02837afb8899c60",
opaque="2e172318130c33ab2488ab6bcea54618"
11:03:32.308 ::*0000001* :: Content-Type: text/html;charset=utf-8
11:03:32.308 ::*0000001* :: Content-Length: 952
11:03:32.308 ::*0000001* :: Date: Mon, 01 May 2006 15:03:32 GMT
11:03:32.308 ::*0000001* ::
11:03:32.308 ::*0000001* :: <html><head><title>Apache Tomcat/5.5.9 - Error
report</title><style><!--H1
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
H2
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
H3
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
BODY
{font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P
{font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
{color : black;}A.name {color : black;}HR {color : #525D76;}--></style>
</head><body><h1>HTTP Status 401 - </h1><HR size="1" noshade="
11:03:32.308 ::*0000001* :: <<<<-------- End
----------------------------------------------->>>>
11:03:32.323 ::*0000001* ::
WinHttpCrackUrlA("http://host:8080/path/to/servlet", 0x41, 0x0, 0x14cf23c)
11:03:32.323 ::*0000001* :: WinHttpCrackUrlA() returning TRUE
11:03:32.323 ::*0000001* :: WinHttpReceiveResponse() returning TRUE
11:03:32.323 ::*0000001* :: WinHttpQueryHeaders(0x15c0000, (0x20000013),
"<null>", 0x14cf510, 0x14cfd54 [4], 0x0 [0])
11:03:32.323 ::*0000001* :: WinHttpQueryHeaders() returning TRUE
11:03:32.323 ::*0000001* :: WinHttpQueryAuthSchemes(0x15c0000, 0x14cf4e0,
0x14cf4dc)
11:03:32.323 ::*0000001* :: WinHttpQueryAuthSchemes() returning TRUE
11:03:32.323 ::*0000001* :: WinHttpSetCredentials(0x15c0000, 0x0, 0x8, "",
"<username>", "<password>")
11:03:32.323 ::*0000001* :: WinHttpSetCredentialsA(0x15c0000, 0x0, 0x8, "",
"<username>", "<password>")
11:03:32.323 ::*0000001* :: WinHttpSetCredentialsA() returning TRUE
11:03:32.323 ::*0000001* :: WinHttpSetCredentials() returning TRUE
11:03:32.323 ::*0000001* :: WinHttpSendRequest(0x15c0000, "", 0, 0xf5bf00,
51, 51, 0)
11:03:32.323 ::*0000001* :: received data:
11:03:32.323 ::*0000001* :: 221 (0xdd) bytes
11:03:32.323 ::*0000001* :: <<<<-------- HTTP stream follows below
----------------------------------------------->>>>
11:03:32.323 ::*0000001* :: noshade"><p><b>type</b> Status
report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>This request
requires HTTP authentication ().</u></p><HR size="1"
noshade="noshade"><h3>Apache Tomcat/5.5.9</h3></body></html>
11:03:32.323 ::*0000001* :: <<<<-------- End
----------------------------------------------->>>>
11:03:32.323 ::*0000001* :: sending data:
11:03:32.323 ::*0000001* :: 567 (0x237) bytes
11:03:32.323 ::*0000001* :: <<<<-------- HTTP stream follows below
----------------------------------------------->>>>
11:03:32.323 ::*0000001* :: POST /path/to/servlet HTTP/1.1
11:03:32.323 ::*0000001* :: User-Agent: WebListen
11:03:32.323 ::*0000001* :: Host: host:8080
11:03:32.323 ::*0000001* :: Content-Length: 51
11:03:32.323 ::*0000001* :: Connection: Keep-Alive
11:03:32.323 ::*0000001* :: Cache-Control: no-cache
11:03:32.323 ::*0000001* :: Pragma: no-cache
11:03:32.323 ::*0000001* :: Authorization: Digest username="user",
realm="realm", qop="auth", algorithm="MD5", uri="/path/to/servlet",
nonce="e69940d4976c0a1de02837afb8899c60", nc=00000001,
cnonce="7f9eb23a5454781370399220d68975f7",
opaque="2e172318130c33ab2488ab6bcea54618",
response="2a4b834f63ca9788b60eb1ad218f4d22"
11:03:32.323 ::*0000001* ::
11:03:32.323 ::*0000001* ::
............#...8.5.1.1.....test.1560972889821568..
11:03:32.323 ::*0000001* :: <<<<-------- End
----------------------------------------------->>>>
11:03:32.323 ::*0000001* :: WinHttpSendRequest() returning TRUE
11:03:32.323 ::*0000001* :: WinHttpReceiveResponse(0x15c0000, 0x0)
11:03:32.323 ::*0000001* :: received data:
11:03:32.323 ::*0000001* :: 133 (0x85) bytes
11:03:32.323 ::*0000001* :: <<<<-------- HTTP stream follows below
----------------------------------------------->>>>
11:03:32.323 ::*0000001* :: HTTP/1.1 200 OK
11:03:32.323 ::*0000001* :: Server: Apache-Coyote/1.1
11:03:32.323 ::*0000001* :: Transfer-Encoding: chunked
11:03:32.323 ::*0000001* :: Date: Mon, 01 May 2006 15:03:32 GMT
11:03:32.323 ::*0000001* ::
11:03:32.323 ::*0000001* :: 10
11:03:32.323 ::*0000001* :: ................
11:03:32.323 ::*0000001* ::
11:03:32.323 ::*0000001* :: <<<<-------- End
----------------------------------------------->>>>
11:03:32.323 ::*0000001* :: WinHttpReceiveResponse() returning TRUE
11:03:32.323 ::*0000001* :: WinHttpQueryHeaders(0x15c0000, (0x20000013),
"<null>", 0x14cf510, 0x14cfd54 [4], 0x0 [0])
11:03:32.323 ::*0000001* :: WinHttpQueryHeaders() returning TRUE
11:03:32.386 ::*0000001* :: WinHttpReadData(0x15c0000, 0x14cfe10, 16,
0x14cfe04)
11:03:32.386 ::*0000001* :: WinHttpReadData() returning TRUE
11:03:32.479 ::*0000001* :: WinHttpReadData(0x15c0000, 0x14cfe10, 16,
0x14cfe04)
11:03:32.479 ::*0000001* :: received data:
11:03:32.479 ::*0000001* :: 16 (0x10) bytes
11:03:32.479 ::*0000001* :: <<<<-------- HTTP stream follows below
----------------------------------------------->>>>
11:03:32.479 ::*0000001* :: b6
11:03:32.479 ::*0000001* :: ............
11:03:32.479 ::*0000001* :: <<<<-------- End
----------------------------------------------->>>>
11:03:32.479 ::*0000001* :: received data:
11:03:32.479 ::*0000001* :: 4 (0x4) bytes
11:03:32.479 ::*0000001* :: <<<<-------- HTTP stream follows below
----------------------------------------------->>>>
11:03:32.479 ::*0000001* :: ....
11:03:32.479 ::*0000001* :: <<<<-------- End
----------------------------------------------->>>>
11:03:32.479 ::*0000001* :: WinHttpReadData() returning TRUE
11:03:32.479 ::*0000001* :: WinHttpReadData(0x15c0000, 0xf58438, 166,
0x14cfdfc)
11:03:32.479 ::*0000001* :: received data:
11:03:32.479 ::*0000001* :: 166 (0xa6) bytes
11:03:32.479 ::*0000001* :: <<<<-------- HTTP stream follows below
----------------------------------------------->>>>
11:03:32.479 ::*0000001* ::
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
11:03:32.479 ::*0000001* :: <<<<-------- End
----------------------------------------------->>>>
11:03:32.479 ::*0000001* :: WinHttpReadData() returning TRUE
11:03:36.479 ::*0000001* :: WinHttpReadData(0x15c0000, 0x14cfe10, 16,
0x14cfe04)
11:03:36.479 ::*0000001* :: received data:
11:03:36.479 ::*0000001* :: 16 (0x10) bytes
11:03:36.479 ::*0000001* :: <<<<-------- HTTP stream follows below
----------------------------------------------->>>>
11:03:36.479 ::*0000001* ::
11:03:36.479 ::*0000001* :: 10
11:03:36.479 ::*0000001* :: ..........
11:03:36.479 ::*0000001* :: <<<<-------- End
----------------------------------------------->>>>
11:03:36.479 ::*0000001* :: received data:
11:03:36.479 ::*0000001* :: 6 (0x6) bytes
11:03:36.479 ::*0000001* :: <<<<-------- HTTP stream follows below
----------------------------------------------->>>>
11:03:36.479 ::*0000001* :: ......
11:03:36.479 ::*0000001* :: <<<<-------- End
----------------------------------------------->>>>
11:03:36.479 ::*0000001* :: WinHttpReadData() returning TRUE
11:03:37.042 ::*Session* :: WinHttpOpen("WebListen", (0), "", "", 0x0)
11:03:37.042 ::*Session* :: WinHttpOpen() returning handle 0x1fb1000
11:03:37.042 ::*Session* ::
WinHttpCrackUrl("http://host:8080/path/to/servlet", 0x0, 0x0, 0x1f2fc3c)
11:03:37.042 ::*Session* ::
WinHttpCrackUrlA("http://host:8080/path/to/servlet", 0x41, 0x0, 0x1f2f26c)
11:03:37.042 ::*Session* :: WinHttpCrackUrlA() returning TRUE
11:03:37.042 ::*Session* :: WinHttpCrackUrl() returning TRUE
11:03:37.042 ::*Session* :: WinHttpConnect(0x1fb1000, "host", 8080, 0x0)
11:03:37.042 ::*Session* :: WinHttpConnect() returning handle 0x1fb1100
11:03:37.042 ::*Session* :: WinHttpOpenRequest(0x1fb1100, "POST",
"/path/to/servlet", "", "", 0x0, 0x00000100)
11:03:37.042 ::*Session* :: WinHttpCreateUrlA(0x1f2f14c, 0x0, 0x1ff0000,
0x1f2f188)
11:03:37.042 ::*Session* :: WinHttpCreateUrlA() returning TRUE
11:03:37.042 ::*0000002* :: WinHttpOpenRequest() returning handle 0x1fe0000
11:03:37.042 ::*0000002* :: WinHttpSendRequest(0x1fe0000, "", 0, 0x1a3b0b0,
34, 34, 0)
11:03:37.042 ::*0000002* :: "host" resolved
11:03:37.058 ::*0000002* :: sending data:
11:03:37.058 ::*0000002* :: 228 (0xe4) bytes
11:03:37.058 ::*0000002* :: <<<<-------- HTTP stream follows below
----------------------------------------------->>>>
11:03:37.058 ::*0000002* :: POST /path/to/servlet HTTP/1.1
11:03:37.058 ::*0000002* :: User-Agent: WebListen
11:03:37.058 ::*0000002* :: Host: host:8080
11:03:37.058 ::*0000002* :: Content-Length: 34
11:03:37.058 ::*0000002* :: Connection: Keep-Alive
11:03:37.058 ::*0000002* :: Cache-Control: no-cache
11:03:37.058 ::*0000002* :: Pragma: no-cache
11:03:37.058 ::*0000002* ::
11:03:37.058 ::*0000002* :: ................8.5.1.1.....test..
11:03:37.058 ::*0000002* :: <<<<-------- End
----------------------------------------------->>>>
11:03:37.058 ::*0000002* :: WinHttpSendRequest() returning TRUE
11:03:37.058 ::*0000002* :: WinHttpReceiveResponse(0x1fe0000, 0x0)
11:03:37.058 ::*0000002* :: received data:
11:03:37.058 ::*0000002* :: 1024 (0x400) bytes
11:03:37.058 ::*0000002* :: <<<<-------- HTTP stream follows below
----------------------------------------------->>>>
11:03:37.058 ::*0000002* :: HTTP/1.1 401 Unauthorized
11:03:37.058 ::*0000002* :: Server: Apache-Coyote/1.1
11:03:37.058 ::*0000002* :: WWW-Authenticate: Digest realm="realm",
qop="auth", nonce="0aa65e7a00f272037a316e8496f86d87",
opaque="b5f3a3a044a8b21a2d79519cc4bfcdac"
11:03:37.058 ::*0000002* :: Content-Type: text/html;charset=utf-8
11:03:37.058 ::*0000002* :: Content-Length: 952
11:03:37.058 ::*0000002* :: Date: Mon, 01 May 2006 15:03:37 GMT
11:03:37.058 ::*0000002* ::
11:03:37.058 ::*0000002* :: <html><head><title>Apache Tomcat/5.5.9 - Error
report</title><style><!--H1
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
H2
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
H3
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
BODY
{font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P
{font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
{color : black;}A.name {color : black;}HR {color : #525D76;}--></style>
</head><body><h1>HTTP Status 401 - </h1><HR size="1" noshade="
11:03:37.058 ::*0000002* :: <<<<-------- End
----------------------------------------------->>>>
11:03:37.058 ::*0000002* ::
WinHttpCrackUrlA("http://host:8080/path/to/servlet", 0x41, 0x0, 0x1f2f160)
11:03:37.058 ::*0000002* :: WinHttpCrackUrlA() returning TRUE
11:03:37.058 ::*0000002* :: WinHttpReceiveResponse() returning TRUE
11:03:37.058 ::*0000002* :: WinHttpQueryHeaders(0x1fe0000, (0x20000013),
"<null>", 0x1f2f434, 0x1f2fc78 [4], 0x0 [0])
11:03:37.058 ::*0000002* :: WinHttpQueryHeaders() returning TRUE
11:03:37.058 ::*0000002* :: WinHttpQueryAuthSchemes(0x1fe0000, 0x1f2f404,
0x1f2f400)
11:03:37.058 ::*0000002* :: WinHttpQueryAuthSchemes() returning TRUE
11:03:37.058 ::*0000002* :: WinHttpSetCredentials(0x1fe0000, 0x0, 0x8, "",
"<username>", "<password>")
11:03:37.058 ::*0000002* :: WinHttpSetCredentialsA(0x1fe0000, 0x0, 0x8, "",
"<username>", "<password>")
11:03:37.058 ::*0000002* :: WinHttpSetCredentialsA: error 87
[ERROR_INVALID_PARAMETER]
11:03:37.058 ::*0000002* :: WinHttpSetCredentialsA() returning FALSE
11:03:37.058 ::*0000002* :: WinHttpSetCredentials() returning FALSE
11:03:37.058 ::*0000002* :: WinHttpCloseHandle(0x1fb1000)
11:03:37.058 ::*0000002* :: WinHttpCloseHandle() returning TRUE
------------------------------END LOG---------------------------------
Post by pbeardsleyHi,
I have multiple threads(each with their own session handle) connecting
syncronously via WinHttp to the same url. The requests are sending data by
POST.
Everything works fine with anonymous access and basic authentication. With
digest authentication, I'm running into a problem.
The first thread makes the initial request, recieves a 401, authenticates
and gets back a 200.
The second thread makes the initial request and gets the 401, but when it
tries to authenticate via WinHttpSetCredentials(), the call fails with
ERROR_INVALID_PARAMETER.
A call to WinHttpQueryAuthSchemes() verifies that digest is supported by the
server. The same exact credentials are sent each time.
Like I said, it works fine for anon and basic auth-- any idea what could be
going on here? Is there a way to get a WinHttp trace report via Perfmon.exe
or anything like that?
Thanks,
Peter Beardsley
Engineer, Loftware Inc.