|
From: <Mik...@su...> - 2002-11-26 19:46:00
|
Here's a patch that fixes a intermittent problem I've been having for a long
time using HtmlUnit to test a application running in the WebSphere Test
Environment within WebSphere Application Developer 4.0.3. The problem occurs
during a HTTP redirect when HttpClient returns a value for the location header
that is a comma delimited list. The patch changes HtmlUnit to ignore everything
after the first value in the list. The code in HttpClient that creates the
comma delimited list is in
org.apache.commons.httpclient.HttpMethodBase.readResponseHeaders(). The code
includes the following comment which is interesting but not enlightening.
* "It must be possible to combine the multiple header fields into one
* "field-name: field-value" pair, without changing the semantics of the
* message, by appending each subsequent field-value to the first, each
* separated by a comma." - HTTP/1.0 (4.3)
Mike Bresnahan
Index: src/java/com/gargoylesoftware/htmlunit/WebClient.java
===================================================================
RCS file:
/cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/WebClient.java,v
retrieving revision 1.23
diff -c -r1.23 WebClient.java
*** src/java/com/gargoylesoftware/htmlunit/WebClient.java 20 Nov 2002
22:19:00 -0000 1.23
--- src/java/com/gargoylesoftware/htmlunit/WebClient.java 26 Nov 2002
19:33:39 -0000
***************
*** 904,910 ****
try {
locationString = webResponse.getResponseHeaderValue
("Location");
if( locationString != null ) {
! newUrl = expandUrl( url, locationString );
}
}
catch( final MalformedURLException e ) {
--- 904,918 ----
try {
locationString = webResponse.getResponseHeaderValue
("Location");
if( locationString != null ) {
! // HttpClient sometimes returns a delimited list of values
where the delimiter is a comma.
! // We'll take a guess and go with the first value.
! int indexOfComma = locationString.indexOf(',');
! if( indexOfComma >= 0) {
! newUrl = expandUrl( url, locationString.substring(0,
indexOfComma));
! }
! else {
! newUrl = expandUrl( url, locationString);
! }
}
}
catch( final MalformedURLException e ) {
|