Index: src/test/org/apache/commons/httpclient/auth/TestDigestAuth.java =================================================================== --- src/test/org/apache/commons/httpclient/auth/TestDigestAuth.java (revision 359204) +++ src/test/org/apache/commons/httpclient/auth/TestDigestAuth.java (working copy) @@ -126,6 +126,22 @@ assertEquals("e95a7ddf37c2eab009568b1ed134f89a", table.get("response")); } + public void testDigestAuthenticationWithQueryStringInDigestURI() throws Exception { + String challenge = "Digest realm=\"realm1\", nonce=\"f2a3f18799759d4f1a1c068b92b573cb\""; + UsernamePasswordCredentials cred = new UsernamePasswordCredentials("username","password"); + FakeHttpMethod method = new FakeHttpMethod("/"); + method.setQueryString("param=value"); + AuthScheme authscheme = new DigestScheme(); + authscheme.processChallenge(challenge); + String response = authscheme.authenticate(cred, method); + Map table = AuthChallengeParser.extractParams(response); + assertEquals("username", table.get("username")); + assertEquals("realm1", table.get("realm")); + assertEquals("/?param=value", table.get("uri")); + assertEquals("f2a3f18799759d4f1a1c068b92b573cb", table.get("nonce")); + assertEquals("a847f58f5fef0bc087bcb9c3eb30e042", table.get("response")); + } + public void testDigestAuthenticationWithMultipleRealms() throws Exception { String challenge1 = "Digest realm=\"realm1\", nonce=\"abcde\""; String challenge2 = "Digest realm=\"realm2\", nonce=\"123546\""; Index: src/java/org/apache/commons/httpclient/auth/DigestScheme.java =================================================================== --- src/java/org/apache/commons/httpclient/auth/DigestScheme.java (revision 359204) +++ src/java/org/apache/commons/httpclient/auth/DigestScheme.java (working copy) @@ -304,7 +304,15 @@ + credentials.getClass().getName()); } getParameters().put("methodname", method.getName()); - getParameters().put("uri", method.getPath()); + StringBuffer buffer = new StringBuffer(method.getPath()); + String query = method.getQueryString(); + if (query != null) { + if (query.indexOf("?") != 0) { + buffer.append("?"); + } + buffer.append(method.getQueryString()); + } + getParameters().put("uri", buffer.toString()); String charset = getParameter("charset"); if (charset == null) { getParameters().put("charset", method.getParams().getCredentialCharset());