Hi ... I'm new to the list, but I'm working for some weeks now with
HttpClient.
Currently I'm trying to solve a problem with Redirects
could it be, that there is a logical bug in
org.apache.commons.httpclient.MethodBase:771 ?
This is the codeblock I mean:
------------------
//get the location header to find out where to redirect to
Header locationHeader = getResponseHeader("location");
if (locationHeader != null) {
// got a redirect response, but no location header
log.error("Received redirect response " + statusCode + " but no
location header");
return statusCode;
}
------------------
IMHO thw test should be if (locationHeader==null)
I also found in org.apache.commons.httpclient.HttpMultiClient that when
there's a redirect,
it is always treated like if it were in strictmode. I think the patch I
supply here, can
solve the issue. please can someone check if this is correct?
mfg Jan
Index: HttpMethodBase.java
===================================================================
RCS file: org/apache/commons/httpclient/HttpMethodBase.java,v
retrieving revision 1.5
diff -u -r1.5 HttpMethodBase.java
--- HttpMethodBase.java 15 Aug 2002 08:31:45 -0000 1.5
+++ HttpMethodBase.java 28 Aug 2002 09:16:58 -0000
@@ -765,10 +765,10 @@
//get the location header to find out where to
redirect to
Header locationHeader =
getResponseHeader("location");
- if (locationHeader != null) {
+ if (locationHeader == null) {
// got a redirect response, but no location
header
log.error("Received redirect response " +
statusCode + " but no location header");
return statusCode;
Index: HttpMultiClient.java
===================================================================
RCS file: /org/apache/commons/httpclient/HttpMultiClient.java,v
retrieving revision 1.1
diff -u -r1.1 HttpMultiClient.java
--- HttpMultiClient.java 6 Aug 2002 17:31:45 -0000 1.1
+++ HttpMultiClient.java 28 Aug 2002 09:16:58 -0000
@@ -329,8 +329,19 @@
+ "header.");
}
- method.recycle();
- method.setUrl(url);
+/*-PATCH BEGIN----------------------
+ */
+ if (!strictMode) {
+ String oUrl=method.getUrl();
+ String nUrl=(new java.net.URL(new
java.net.URL(oUrl),url)).toExternalForm();
+ method.recycle();
+ method.setUrl(nUrl);
+ } else {
+ method.recycle();
+ method.setUrl(url);
+ }
+/*
+--PATCH END ---------------------*/
return executeMethod(method);
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>