olegk 2003/08/12 11:45:04
Modified: httpclient/src/java/org/apache/commons/httpclient Tag:
HTTPCLIENT_2_0_BRANCH HttpMethodBase.java
Log:
The patch addresses the problem with the proxy authentication realm reported by
David Rowe <[EMAIL PROTECTED]>.
HttpMethodBase changed to correctly determine authentication realm
Contributed by Oleg Kalnichevski
Reviewed by Michael Becke & Ortwin Glueck
Revision Changes Path
No revision
No revision
1.159.2.8 +19 -13
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java
Index: HttpMethodBase.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
retrieving revision 1.159.2.7
retrieving revision 1.159.2.8
diff -u -r1.159.2.7 -r1.159.2.8
--- HttpMethodBase.java 12 Aug 2003 02:39:41 -0000 1.159.2.7
+++ HttpMethodBase.java 12 Aug 2003 18:45:03 -0000 1.159.2.8
@@ -2461,14 +2461,20 @@
// handle authentication required
Header[] challenges = null;
Set realmsUsed = null;
+ String host = null;
switch (statusCode) {
case HttpStatus.SC_UNAUTHORIZED:
challenges =
getResponseHeaderGroup().getHeaders(HttpAuthenticator.WWW_AUTH);
realmsUsed = realms;
+ host = conn.getVirtualHost();
+ if (host == null) {
+ host = conn.getHost();
+ }
break;
case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
challenges =
getResponseHeaderGroup().getHeaders(HttpAuthenticator.PROXY_AUTH);
realmsUsed = proxyRealms;
+ host = conn.getProxyHost();
break;
}
boolean authenticated = false;
@@ -2490,21 +2496,21 @@
}
StringBuffer buffer = new StringBuffer();
- buffer.append(conn.getHost());
- int port = conn.getPort();
- if (conn.getProtocol().getDefaultPort() != port) {
- buffer.append(':');
- buffer.append(port);
- }
+ buffer.append(host);
buffer.append('#');
buffer.append(authscheme.getID());
String realm = buffer.toString();
if (realmsUsed.contains(realm)) {
if (LOG.isInfoEnabled()) {
- LOG.info("Already tried to authenticate to \""
- + realm + "\" but still receiving "
- + statusCode + ".");
+ buffer = new StringBuffer();
+ buffer.append("Already tried to authenticate with '");
+ buffer.append(authscheme.getRealm());
+ buffer.append("' authentication realm at ");
+ buffer.append(host);
+ buffer.append(", but still receiving: ");
+ buffer.append(statusLine.toString());
+ LOG.info(buffer.toString());
}
return true;
} else {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]