rwaldhoff 01/08/13 17:25:16
Modified: httpclient/src/java/org/apache/commons/httpclient Tag:
rlwrefactoring HttpMethodBase.java
Log:
no need to loop on failure, or track number of repeats.
Revision Changes Path
No revision
No revision
1.10.2.11 +25 -27
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.10.2.10
retrieving revision 1.10.2.11
diff -u -r1.10.2.10 -r1.10.2.11
--- HttpMethodBase.java 2001/08/13 23:55:35 1.10.2.10
+++ HttpMethodBase.java 2001/08/14 00:25:16 1.10.2.11
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
1.10.2.10 2001/08/13 23:55:35 rwaldhoff Exp $
- * $Revision: 1.10.2.10 $
- * $Date: 2001/08/13 23:55:35 $
+ * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
1.10.2.11 2001/08/14 00:25:16 rwaldhoff Exp $
+ * $Revision: 1.10.2.11 $
+ * $Date: 2001/08/14 00:25:16 $
* ====================================================================
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
@@ -65,7 +65,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a>
* @author Rodney Waldhoff
- * @version $Id: HttpMethodBase.java,v 1.10.2.10 2001/08/13 23:55:35 rwaldhoff Exp $
+ * @version $Id: HttpMethodBase.java,v 1.10.2.11 2001/08/14 00:25:16 rwaldhoff Exp $
*/
public abstract class HttpMethodBase implements HttpMethod {
@@ -364,20 +364,21 @@
Set visited = new HashSet();
Set realms = new HashSet();
- int repeated = 0;
- while(repeated++ < 5) {
+ for(;;) {
// for now, just track path
visited.add(getPath());
- log.debug("HttpMethodBase.execute(): looping " + repeated);
+ log.debug("HttpMethodBase.execute(): looping.");
+
if(!connection.isOpen()) {
log.debug("HttpMethodBase.execute(): opening connection.");
connection.open();
}
+
writeRequest(state,connection);
used = true;
- // need to close output?
+ // need to close output?, but when?
readResponse(state,connection);
@@ -392,21 +393,14 @@
}
}
- if(statusCode < HttpStatus.SC_OK) {
- if(HttpStatus.SC_CONTINUE == statusCode) {
- if(!bodySent) {
- bodySent = writeRequestBody(state,connection);
- } else {
- // error? 100 response, but I've already written the body
- return statusCode;
- }
+ if(HttpStatus.SC_CONTINUE == statusCode) {
+ if(!bodySent) {
+ bodySent = writeRequestBody(state,connection);
+ readResponse(state,connection);
+ } else {
+ log.warn("HttpMethodBase.execute(): received 100 response, but
I've already sent the response.");
+ break;
}
- // parse the second response
- readResponse(state,connection);
- }
-
- if(statusCode == HttpStatus.SC_OK) {
- return statusCode;
}
if(HttpStatus.SC_UNAUTHORIZED == statusCode) {
@@ -416,7 +410,7 @@
if(realms.contains(foo)) {
if(log.isInfoEnabled()) {
log.info("Already tried to authenticate to \"" +
wwwauth.getValue() + "\" but still receiving " + HttpStatus.SC_UNAUTHORIZED + ".");
- return HttpStatus.SC_UNAUTHORIZED;
+ break;
}
} else {
realms.add(foo);
@@ -464,7 +458,8 @@
// to "https://secure.mydomain.com/"
//
- // XXX Should handle query-string changes as well!
+ // XXX FIX ME XXX
+ // Should handle query-string changes as well!
Header location = getResponseHeader("location");
if(location != null) {
@@ -501,15 +496,18 @@
if(log.isInfoEnabled()) {
log.info("HttpMethodBase.execute(): Received " +
statusCode + " response, but no \"Location\" header. Returning " + statusCode + ".");
}
- return statusCode;
+ break;
}
} else {
// got a redirect response,
// but followRedirects is false
- return statusCode;
+ log.info("HttpMethodBase.execute(): Received " + statusCode + "
response, but followRedirects is false. Returning " + statusCode + ".");
+ break;
}
} else {
- return statusCode;
+ // neither an UNAUTHORIZED nor a redirect response
+ // so exit
+ break;
}
}