cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2004-11-09 Thread olegk
olegk   2004/11/09 11:25:43

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Fix for a superfluous info message in responseBodyConsumed method
  
  Contributed by Oleg Kalnichevski
  
  Revision  ChangesPath
  1.220 +20 -19
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.219
  retrieving revision 1.220
  diff -u -r1.219 -r1.220
  --- HttpMethodBase.java   19 Oct 2004 18:09:45 -  1.219
  +++ HttpMethodBase.java   9 Nov 2004 19:25:42 -   1.220
  @@ -2248,23 +2248,24 @@
   // If there is data available, regard the connection as being
   // unreliable and close it.
   
  -try {
  -if(responseConnection.isResponseAvailable()) {
  -boolean logExtraInput =
  -
getParams().isParameterTrue(HttpMethodParams.WARN_EXTRA_INPUT);
  -
  -if(logExtraInput) {
  -LOG.warn(Extra response data detected - closing 
connection);
  -} 
  -setConnectionCloseForced(true);
  -}
  -}
  -catch (IOException e) {
  -LOG.info(e.getMessage());
  -responseConnection.close();
  -}
   if (shouldCloseConnection(responseConnection)) {
   responseConnection.close();
  +} else {
  +try {
  +if(responseConnection.isResponseAvailable()) {
  +boolean logExtraInput =
  +
getParams().isParameterTrue(HttpMethodParams.WARN_EXTRA_INPUT);
  +
  +if(logExtraInput) {
  +LOG.warn(Extra response data detected - closing 
connection);
  +} 
  +responseConnection.close();
  +}
  +}
  +catch (IOException e) {
  +LOG.warn(e.getMessage());
  +responseConnection.close();
  +}
   }
   }
   this.connectionCloseForced = false;
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2004-09-17 Thread oglueck
oglueck 2004/09/17 00:51:41

  Modified:httpclient/src/java/org/apache/commons/httpclient Tag:
HTTPCLIENT_2_0_BRANCH HttpMethodBase.java
  Log:
  add API Doc about buffering
  add a warning if the buffered content length is unknown or  1 MB
  optimization of buffer allocation
  PR: 31246, 30388
  Reviewed by: Oleg Kalnichevski
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.159.2.32 +29 -7 
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.31
  retrieving revision 1.159.2.32
  diff -u -r1.159.2.31 -r1.159.2.32
  --- HttpMethodBase.java   19 Aug 2004 21:38:12 -  1.159.2.31
  +++ HttpMethodBase.java   17 Sep 2004 07:51:40 -  1.159.2.32
  @@ -223,6 +223,12 @@
   /** Number of milliseconds to wait for 100-contunue response. */
   private static final int RESPONSE_WAIT_TIME_MS = 3000;
   
  +/** Maximum buffered response size (in bytes) that triggers no warning. */
  +private static final int BUFFER_WARN_TRIGGER_LIMIT = 1024*1024; //1 MB
  +
  +/** Default initial size of the response buffer if content length is unknown. */
  +private static final int DEFAULT_INITIAL_BUFFER_SIZE = 4*1024; // 4 kB
  +
   // --- Constructors
   
   /**
  @@ -669,7 +675,12 @@
   
   /**
* Returns the response body of the HTTP method, if any, as an array of bytes.
  - * If response body is not available or cannot be read, returns ttnull/tt
  + * If response body is not available or cannot be read, returns ttnull/tt.
  + * 
  + * Note: This will cause the entire response body to be buffered in memory. A
  + * malicious server may easily exhaust all the VM memory. It is strongly
  + * recommended, to use getResponseAsStream if the content length of the response
  + * is unknown or resonably large.
* 
* @return The response body.
*/
  @@ -678,8 +689,14 @@
   try {
   InputStream instream = getResponseBodyAsStream();
   if (instream != null) {
  +int contentLength = getResponseContentLength();
  +if ((contentLength == -1) || (contentLength  
BUFFER_WARN_TRIGGER_LIMIT)) {
  +LOG.warn(Going to buffer response body of large or unknown 
size. 
  ++Using getResponseAsStream instead is 
recommended.);
  +}
   LOG.debug(Buffering response body);
  -ByteArrayOutputStream outstream = new ByteArrayOutputStream();
  +ByteArrayOutputStream outstream = new ByteArrayOutputStream(
  +contentLength  0 ? contentLength : 
DEFAULT_INITIAL_BUFFER_SIZE);
   byte[] buffer = new byte[4096];
   int len;
   while ((len = instream.read(buffer))  0) {
  @@ -723,7 +740,12 @@
* If response body is not available or cannot be read, returns ttnull/tt
* The string conversion on the data is done using the character encoding 
specified
* in ttContent-Type/tt header.
  - *
  + * 
  + * Note: This will cause the entire response body to be buffered in memory. A
  + * malicious server may easily exhaust all the VM memory. It is strongly
  + * recommended, to use getResponseAsStream if the content length of the response
  + * is unknown or resonably large.
  + * 
* @return The response body.
*/
   public String getResponseBodyAsString() {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2004-08-19 Thread olegk
olegk   2004/08/19 14:38:13

  Modified:httpclient/src/java/org/apache/commons/httpclient Tag:
HTTPCLIENT_2_0_BRANCH HttpMethodBase.java
  Log:
  Tone down warning messages generated by the readResponseBody method when 
encountering non-fatal protocol violations
  
  Contributed by Oleg Kalnichevski
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.159.2.31 +9 -12 
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.30
  retrieving revision 1.159.2.31
  diff -u -r1.159.2.30 -r1.159.2.31
  --- HttpMethodBase.java   27 Jul 2004 01:34:48 -  1.159.2.30
  +++ HttpMethodBase.java   19 Aug 2004 21:38:12 -  1.159.2.31
  @@ -2008,9 +2008,9 @@
   private InputStream readResponseBody(HttpConnection conn)
   throws IOException {
   
  -LOG.trace(enter HttpMethodBase.readResponseBody(HttpState, 
HttpConnection));
  +LOG.trace(enter HttpMethodBase.readResponseBody(HttpConnection));
   
  -responseBody = null; // is this desired?
  +responseBody = null;
   InputStream is = conn.getResponseInputStream();
   if (Wire.CONTENT_WIRE.enabled()) {
   is = new WireLogInputStream(is, Wire.CONTENT_WIRE);
  @@ -2044,10 +2044,7 @@
   }
   }
   } else {
  -if (LOG.isWarnEnabled()) {
  -LOG.warn(Transfer-Encoding is set but does not contain 
\chunked\: 
  -+ transferEncoding);
  -}
  +LOG.info(Response content is not chunk-encoded);
   // The connection must be terminated by closing 
   // the socket as per RFC 2616, 3.6
   setConnectionCloseForced(true);
  @@ -2062,8 +2059,8 @@
   if (connectionHeader != null) {
   connectionDirective = connectionHeader.getValue();
   }
  -if (!close.equalsIgnoreCase(connectionDirective)) {
  -LOG.warn(Response content length is not known);
  +if (isHttp11()  
!close.equalsIgnoreCase(connectionDirective)) {
  +LOG.info(Response content length is not known);
   setConnectionCloseForced(true);
   }
   result = is;
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2004-08-19 Thread olegk
olegk   2004/08/19 14:39:26

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Tone down warning messages generated by the readResponseBody method when 
encountering non-fatal protocol violations
  
  Contributed by Oleg Kalnichevski
  
  Revision  ChangesPath
  1.211 +10 -12
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.210
  retrieving revision 1.211
  diff -u -r1.210 -r1.211
  --- HttpMethodBase.java   5 Jul 2004 22:46:58 -   1.210
  +++ HttpMethodBase.java   19 Aug 2004 21:39:26 -  1.211
  @@ -1630,9 +1630,9 @@
   private InputStream readResponseBody(HttpConnection conn)
   throws HttpException, IOException {
   
  -LOG.trace(enter HttpMethodBase.readResponseBody(HttpState, 
HttpConnection));
  +LOG.trace(enter HttpMethodBase.readResponseBody(HttpConnection));
   
  -responseBody = null; // is this desired?
  +responseBody = null;
   InputStream is = conn.getResponseInputStream();
   if (Wire.CONTENT_WIRE.enabled()) {
   is = new WireLogInputStream(is, Wire.CONTENT_WIRE);
  @@ -1666,10 +1666,7 @@
   }
   }
   } else {
  -if (LOG.isWarnEnabled()) {
  -LOG.warn(Transfer-Encoding is set but does not contain 
\chunked\: 
  -+ transferEncoding);
  -}
  +LOG.info(Response content is not chunk-encoded);
   // The connection must be terminated by closing 
   // the socket as per RFC 2616, 3.6
   setConnectionCloseForced(true);
  @@ -1684,8 +1681,9 @@
   if (connectionHeader != null) {
   connectionDirective = connectionHeader.getValue();
   }
  -if (!close.equalsIgnoreCase(connectionDirective)) {
  -LOG.warn(Response content length is not known);
  +if (this.effectiveVersion.greaterEquals(HttpVersion.HTTP_1_1) 
 
  +!close.equalsIgnoreCase(connectionDirective)) {
  +LOG.info(Response content length is not known);
   setConnectionCloseForced(true);
   }
   result = is;
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2004-02-15 Thread mbecke
mbecke  2004/02/15 07:48:43

  Modified:httpclient/xdocs Tag: HTTPCLIENT_2_0_BRANCH status.xml
news.xml downloads.xml
   httpclient Tag: HTTPCLIENT_2_0_BRANCH build.xml project.xml
   httpclient/src/java/org/apache/commons/httpclient Tag:
HTTPCLIENT_2_0_BRANCH HttpMethodBase.java
  Log:
  Updates for 2.0 final release.
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.20.2.6  +14 -18jakarta-commons/httpclient/xdocs/status.xml
  
  Index: status.xml
  ===
  RCS file: /home/cvs/jakarta-commons/httpclient/xdocs/status.xml,v
  retrieving revision 1.20.2.5
  retrieving revision 1.20.2.6
  diff -u -r1.20.2.5 -r1.20.2.6
  --- status.xml16 Jan 2004 21:34:33 -  1.20.2.5
  +++ status.xml15 Feb 2004 15:48:42 -  1.20.2.6
  @@ -4,33 +4,30 @@
   
 properties
   titleStatus/title
  -author email=[EMAIL PROTECTED]Commons Documentation Team/author
  -author email=[EMAIL PROTECTED]Remy Maucherat/author
  -author email=[EMAIL PROTECTED]Rodney Waldhoff/author
  -author email=[EMAIL PROTECTED]Jeff Dever/author
  +author email=[EMAIL PROTECTED]Commons HttpClient Team/author
   revision$Id$/revision
 /properties
   
 body
   
   section name=Current Status  
  -pThe HttpClient development team is pleased to announce the third release 
candidate 
  -of emHttpClient 2.0/em. We are confident that emHttpClient 2.0/em 
has reached 
  -the required level of maturity, and we hope to have a final 2.0 release 
soon./p
  -
  - pOnly critical or major bug fixes and javadocs enhancements will be made to 
the 2.0 
  -code base before the final release./p
  -
  - pMeanwhile, the HttpClient development team has been busy working toward a 
post 2.0
  - release. The next version of emHttpClient/em is going to build upon the 
  -foundation laid with emHttpClient 2.0/em while addressing those 
architectural 
  +pThe HttpClient development team is pleased to announce the final release 
of
  +emHttpClient 2.0/em. Much effort has gone into the 2.0 release and we 
are
  +confident that it is ready for the Final 2.0 designation./p
  +
  + pFrom this point forward only bugs fixes will be added to the 2.0 branch.  
Efforts 
  + will now be focused on the next major HttpClient release./p
  +
  + pThe next version of emHttpClient/em is going to build upon the 
  +foundation laid with emHttpClient 2.0/em, while addressing those 
architectural 
   shortcomings and flaws identified in the course of 2.0 development. Several 
well known 
   and much complained about problems cannot be resolved while maintaining 
complete 2.0 API 
   compatibility. The primary objective of the next version is to fix those 
design limitations, 
   breaking 2.0 API compatibility where absolutely unavoidable, while 
preserving overall 
   compatibility with 2.0 use patterns./p
   
  -   pWe already have a new preference architecture in place that will help us 
provide a
  +   pA number of enhancements have already been made to the post-2.0 codebase. 
We 
  + already have a new preference architecture in place that will help us 
provide a
   fine-grained control over HttpClient without polluting its API with too 
many options. We 
   have also completely reworked redirect/authentication/retry logic and can 
now support 
   cross-host redirects, a much complained about limitation of emHttpClient 
2.0/em./p
  @@ -46,8 +43,7 @@
   
   section name=Release Info
 pCurrent Release: a 
href=http://jakarta.apache.org/builds/jakarta-commons/release/commons-httpclient/v2.0/;
  -  Release 2.0 Release Candidate 3/a/p
  -  pPlanned Next Release: 2.0 Final/p
  +  Release 2.0 Final/a/p
   /section
   
 /body
  
  
  
  1.20.2.8  +9 -5  jakarta-commons/httpclient/xdocs/news.xml
  
  Index: news.xml
  ===
  RCS file: /home/cvs/jakarta-commons/httpclient/xdocs/news.xml,v
  retrieving revision 1.20.2.7
  retrieving revision 1.20.2.8
  diff -u -r1.20.2.7 -r1.20.2.8
  --- news.xml  17 Jan 2004 02:57:03 -  1.20.2.7
  +++ news.xml  15 Feb 2004 15:48:42 -  1.20.2.8
  @@ -3,20 +3,24 @@
   
 properties
   titleHttpClient News/title
  -author email=[EMAIL PROTECTED]Commons Documentation Team/author
  -author email=[EMAIL PROTECTED]Rodney Waldhoff/author
  -author email=[EMAIL PROTECTED]Jeff Dever/author
  +author email=[EMAIL PROTECTED]Commons HttpClient Team/author
   revision$Id$/revision
 /properties
   
 body
   
  +section name=15 February 2004 - HttpClient 2.0 Final released
  +

cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2004-01-16 Thread mbecke
mbecke  2004/01/16 13:34:34

  Modified:httpclient/xdocs Tag: HTTPCLIENT_2_0_BRANCH status.xml
news.xml downloads.xml
   httpclient Tag: HTTPCLIENT_2_0_BRANCH build.xml project.xml
   httpclient/src/java/org/apache/commons/httpclient Tag:
HTTPCLIENT_2_0_BRANCH HttpMethodBase.java
  Log:
  2.0 RC3 updates.
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.20.2.5  +4 -5  jakarta-commons/httpclient/xdocs/status.xml
  
  Index: status.xml
  ===
  RCS file: /home/cvs/jakarta-commons/httpclient/xdocs/status.xml,v
  retrieving revision 1.20.2.4
  retrieving revision 1.20.2.5
  diff -u -r1.20.2.4 -r1.20.2.5
  --- status.xml12 Oct 2003 04:02:20 -  1.20.2.4
  +++ status.xml16 Jan 2004 21:34:33 -  1.20.2.5
  @@ -14,10 +14,9 @@
 body
   
   section name=Current Status  
  -pThe HttpClient development team is pleased to announce the second 
release candidate 
  +pThe HttpClient development team is pleased to announce the third release 
candidate 
   of emHttpClient 2.0/em. We are confident that emHttpClient 2.0/em 
has reached 
  -the required level of maturity, and we hope to have a final 2.0 release by 
the end of 
  -October 2003./p
  +the required level of maturity, and we hope to have a final 2.0 release 
soon./p
   
pOnly critical or major bug fixes and javadocs enhancements will be made to 
the 2.0 
   code base before the final release./p
  @@ -47,7 +46,7 @@
   
   section name=Release Info
 pCurrent Release: a 
href=http://jakarta.apache.org/builds/jakarta-commons/release/commons-httpclient/v2.0/;
  -  Release 2.0 Release Candidate 2/a/p
  +  Release 2.0 Release Candidate 3/a/p
 pPlanned Next Release: 2.0 Final/p
   /section
   
  
  
  
  1.20.2.6  +8 -1  jakarta-commons/httpclient/xdocs/news.xml
  
  Index: news.xml
  ===
  RCS file: /home/cvs/jakarta-commons/httpclient/xdocs/news.xml,v
  retrieving revision 1.20.2.5
  retrieving revision 1.20.2.6
  diff -u -r1.20.2.5 -r1.20.2.6
  --- news.xml  12 Oct 2003 04:02:20 -  1.20.2.5
  +++ news.xml  16 Jan 2004 21:34:33 -  1.20.2.6
  @@ -11,6 +11,13 @@
   
 body
   
  +section name=16 January 2004 - HttpClient 2.0 Release Candidate 3 released
  +  pWhile a final 2.0 release still eludes us, we have continued to make
  +   good progress.  This release fixes some significant bugs that crept into RC2.
  +   Assuming that there are no major bugs found in this release a final release 
should 
  +   follow shortly./p
  +/section
  +
   section name=13 October 2003 - HttpClient 2.0 Release Candidate 2 released
 pReleasing a final version of HttpClient 2.0 by the end of Summer 2003, as 
  originally planned, was not possible. There were a significant number of 
minor 
  
  
  
  1.19.2.6  +3 -3  jakarta-commons/httpclient/xdocs/downloads.xml
  
  Index: downloads.xml
  ===
  RCS file: /home/cvs/jakarta-commons/httpclient/xdocs/downloads.xml,v
  retrieving revision 1.19.2.5
  retrieving revision 1.19.2.6
  diff -u -r1.19.2.5 -r1.19.2.6
  --- downloads.xml 4 Nov 2003 02:17:57 -   1.19.2.5
  +++ downloads.xml 16 Jan 2004 21:34:33 -  1.19.2.6
  @@ -16,7 +16,7 @@
The following releases are available for download:
  /p
  ul
  - li2.0 Release Candidate 2 - 13 October 2003 - 
  + li2.0 Release Candidate 3 - 16 January 2004 - 
   a href=http://jakarta.apache.org/site/binindex.cgi;Binary/a and 
   a href=http://jakarta.apache.org/site/sourceindex.cgi;Source/a/li
  /ul
  @@ -44,7 +44,7 @@
source![CDATA[
   dependency
   idcommons-httpclient/id
  -version2.0-rc2/version
  +version2.0-rc3/version
   urlhttp://jakarta.apache.org/commons/httpclient//url
   /dependency
]]/source
  
  
  
  No   revision
  No   revision
  1.29.2.3  +2 -2  jakarta-commons/httpclient/build.xml
  
  Index: build.xml
  ===
  RCS file: /home/cvs/jakarta-commons/httpclient/build.xml,v
  retrieving revision 1.29.2.2
  retrieving revision 1.29.2.3
  diff -u -r1.29.2.2 -r1.29.2.3
  --- build.xml 12 Oct 2003 04:02:20 -  1.29.2.2
  +++ build.xml 16 Jan 2004 21:34:33 -  1.29.2.3
  @@ -37,7 +37,7 @@
 property name=component.title value=HttpClient Library/
   
 !-- The current version number of this component --
  -  property name=component.version   value=2.0-rc2/
  +  property name=component.version   

cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-12-18 Thread mbecke
mbecke  2003/12/18 22:02:13

  Modified:httpclient/src/test/org/apache/commons/httpclient Tag:
HTTPCLIENT_2_0_BRANCH
TestHttpConnectionManager.java
   httpclient/src/java/org/apache/commons/httpclient Tag:
HTTPCLIENT_2_0_BRANCH HttpMethodBase.java
  Log:
  Connections are now closed and released automatically when an unrecoverable
  exception occurs in HttpMethodBase.processRequest().
  
  PR: 25370
  Submitted by: Michael Becke
  Reviewed by: Oleg Kalnichevski
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.8.2.3   +37 -4 
jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestHttpConnectionManager.java
  
  Index: TestHttpConnectionManager.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestHttpConnectionManager.java,v
  retrieving revision 1.8.2.2
  retrieving revision 1.8.2.3
  diff -u -r1.8.2.2 -r1.8.2.3
  --- TestHttpConnectionManager.java19 Nov 2003 13:27:42 -  1.8.2.2
  +++ TestHttpConnectionManager.java19 Dec 2003 06:02:13 -  1.8.2.3
  @@ -246,6 +246,39 @@
   assertNull(connectionManager should be null, connectionManager);
   }
   
  +public void testWriteRequestReleaseConnection() {
  +
  +MultiThreadedHttpConnectionManager connectionManager = new 
MultiThreadedHttpConnectionManager();
  +connectionManager.setMaxConnectionsPerHost(1);
  +
  +HttpClient client = createHttpClient(connectionManager);
  +
  +GetMethod get = new GetMethod(/) {
  +protected boolean writeRequestBody(HttpState state, HttpConnection conn)
  +throws IOException, HttpException {
  +throw new IOException(Oh no!!);
  +}
  +};
  +
  +try {
  +client.executeMethod(get);
  +fail(An exception should have occurred.);
  +} catch (HttpException e) {
  +e.printStackTrace();
  +fail(HttpException should not have occurred:  + e);
  +} catch (IOException e) {
  +// expected
  +}
  +
  +try {
  +connectionManager.getConnection(client.getHostConfiguration(), 1);
  +} catch (HttpException e) {
  +e.printStackTrace();
  +fail(Connection was not released:  + e);
  +}
  +
  +}
  +
   public void testReleaseConnection() {
   
   MultiThreadedHttpConnectionManager connectionManager = new 
MultiThreadedHttpConnectionManager();
  
  
  
  No   revision
  No   revision
  1.159.2.21 +12 -4 
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.20
  retrieving revision 1.159.2.21
  diff -u -r1.159.2.20 -r1.159.2.21
  --- HttpMethodBase.java   14 Dec 2003 22:41:37 -  1.159.2.20
  +++ HttpMethodBase.java   19 Dec 2003 06:02:13 -  1.159.2.21
  @@ -2685,6 +2685,14 @@
   doneWithConnection = true;
   throw httpre;
   }
  +} catch (IOException e) {
  +connection.close();
  +doneWithConnection = true;
  +throw e;
  +} catch (RuntimeException e) {
  +connection.close();
  +doneWithConnection = true;
  +throw e;
   }
   }
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-12-14 Thread mbecke
mbecke  2003/12/14 14:39:04

  Modified:httpclient/src/java/org/apache/commons/httpclient/util
HttpURLConnection.java
   httpclient/src/java/org/apache/commons/httpclient/methods
PostMethod.java EntityEnclosingMethod.java
   httpclient/src/java/org/apache/commons/httpclient/auth
HttpAuthRealm.java
   httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Fixes for unmatched javadoc tt and code tags.
  
  PR: 25004
  Submitted by: Michael Becke
  
  Revision  ChangesPath
  1.13  +5 -5  
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/util/HttpURLConnection.java
  
  Index: HttpURLConnection.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/util/HttpURLConnection.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- HttpURLConnection.java22 Apr 2003 18:11:01 -  1.12
  +++ HttpURLConnection.java14 Dec 2003 22:39:03 -  1.13
  @@ -79,7 +79,7 @@
* Provides a codeHttpURLConnection/code wrapper around HttpClient's
* codeHttpMethod/code. This allows existing code to easily switch to
* HttpClieht without breaking existing interfaces using the JDK
  - * codeHttpURLConnectioncode.
  + * codeHttpURLConnection/code.
*
* Note 1: The current implementations wraps only a connected
* codeHttpMethod/code, ie a method that has alreayd been used to connect
  
  
  
  1.50  +5 -5  
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PostMethod.java
  
  Index: PostMethod.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PostMethod.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- PostMethod.java   12 Sep 2003 07:34:16 -  1.49
  +++ PostMethod.java   14 Dec 2003 22:39:03 -  1.50
  @@ -199,7 +199,7 @@
* /p   
* 
* @return request body as an array of bytes. If the request content 
  - *  has not been set, returns ttnull/null.
  + *  has not been set, returns ttnull/tt.
* 
* @since 2.0beta1
*/
  
  
  
  1.27  +5 -5  
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java
  
  Index: EntityEnclosingMethod.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- EntityEnclosingMethod.java9 Aug 2003 19:37:58 -   1.26
  +++ EntityEnclosingMethod.java14 Dec 2003 22:39:04 -  1.27
  @@ -196,7 +196,7 @@
* alternative request content input methods./p
* 
* @return request body as an array of bytes. If the request content 
  - *  has not been set, returns ttnull/null.
  + *  has not been set, returns ttnull/tt.
* 
* @since 2.0beta1
*/
  
  
  
  1.4   +5 -5  
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/auth/HttpAuthRealm.java
  
  Index: HttpAuthRealm.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/auth/HttpAuthRealm.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HttpAuthRealm.java26 May 2003 21:51:37 -  1.3
  +++ HttpAuthRealm.java14 Dec 2003 22:39:04 -  1.4
  @@ -80,10 +80,10 @@
* ttrealm/tt.
* 
* @param domain the domain the credentials apply to. May be set
  - *   to ttnull/null if credenticals are applicable to
  + *   to ttnull/tt if credenticals are applicable to
*   any domain. 
* @param realm the realm the credentials apply to. May be set 
  - *   to ttnull/null if credenticals are applicable to
  + *   to ttnull/tt if credenticals are applicable to
*   any realm. 
*   
*/
  
  
  
  1.195 +7 -7  
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.194
  retrieving revision 1.195
  diff -u -r1.194 -r1.195
  --- HttpMethodBase.java   11 Dec 2003 22:54:18 -  1.194
  +++ HttpMethodBase.java   14 Dec 2003 22:39:04 

cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-12-14 Thread mbecke
mbecke  2003/12/14 14:41:37

  Modified:httpclient/src/java/org/apache/commons/httpclient/methods
Tag: HTTPCLIENT_2_0_BRANCH PostMethod.java
EntityEnclosingMethod.java MultipartPostMethod.java
   httpclient/src/java/org/apache/commons/httpclient/auth Tag:
HTTPCLIENT_2_0_BRANCH HttpAuthRealm.java
   httpclient/src/java/org/apache/commons/httpclient/util Tag:
HTTPCLIENT_2_0_BRANCH HttpURLConnection.java
   httpclient/src/java/org/apache/commons/httpclient Tag:
HTTPCLIENT_2_0_BRANCH HttpMethodBase.java
  Log:
  Fixes for unmatched javadoc tt and code tags.
  
  PR: 25004
  Submitted by: Michael Becke
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.45.2.4  +5 -5  
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PostMethod.java
  
  Index: PostMethod.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PostMethod.java,v
  retrieving revision 1.45.2.3
  retrieving revision 1.45.2.4
  diff -u -r1.45.2.3 -r1.45.2.4
  --- PostMethod.java   12 Sep 2003 07:33:20 -  1.45.2.3
  +++ PostMethod.java   14 Dec 2003 22:41:37 -  1.45.2.4
  @@ -226,7 +226,7 @@
* /p   
* 
* @return request body as an array of bytes. If the request content 
  - *  has not been set, returns ttnull/null.
  + *  has not been set, returns ttnull/tt.
* 
* @since 2.0beta1
*/
  
  
  
  1.18.2.3  +5 -5  
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java
  
  Index: EntityEnclosingMethod.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java,v
  retrieving revision 1.18.2.2
  retrieving revision 1.18.2.3
  diff -u -r1.18.2.2 -r1.18.2.3
  --- EntityEnclosingMethod.java4 Oct 2003 02:31:26 -   1.18.2.2
  +++ EntityEnclosingMethod.java14 Dec 2003 22:41:37 -  1.18.2.3
  @@ -223,7 +223,7 @@
* alternative request content input methods./p
* 
* @return request body as an array of bytes. If the request content 
  - *  has not been set, returns ttnull/null.
  + *  has not been set, returns ttnull/tt.
* 
* @since 2.0beta1
*/
  
  
  
  1.17.2.2  +4 -4  
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/MultipartPostMethod.java
  
  Index: MultipartPostMethod.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/MultipartPostMethod.java,v
  retrieving revision 1.17.2.1
  retrieving revision 1.17.2.2
  diff -u -r1.17.2.1 -r1.17.2.2
  --- MultipartPostMethod.java  9 Aug 2003 19:36:39 -   1.17.2.1
  +++ MultipartPostMethod.java  14 Dec 2003 22:41:37 -  1.17.2.2
  @@ -83,7 +83,7 @@
* Implements the HTTP multipart POST method.
* p
* The HTTP multipart POST method is defined in section 3.3 of
  - * a href=http://http://www.ietf.org/rfc/rfc1867.txt;RFC1867/a:
  + * a href=http://www.ietf.org/rfc/rfc1867.txt;RFC1867/a:
* blockquote
* The media-type multipart/form-data follows the rules of all multipart
* MIME data streams as outlined in RFC 1521. The multipart/form-data contains 
  
  
  
  No   revision
  No   revision
  1.3.2.1   +5 -5  
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/auth/HttpAuthRealm.java
  
  Index: HttpAuthRealm.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/auth/HttpAuthRealm.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- HttpAuthRealm.java26 May 2003 21:51:37 -  1.3
  +++ HttpAuthRealm.java14 Dec 2003 22:41:37 -  1.3.2.1
  @@ -80,10 +80,10 @@
* ttrealm/tt.
* 
* @param domain the domain the credentials apply to. May be set
  - *   to ttnull/null if credenticals are applicable to
  + *   to ttnull/tt if credenticals are applicable to
*   any domain. 
* @param realm the realm the credentials apply to. May be set 
  - *   to ttnull/null if credenticals are applicable to
  + *   to ttnull/tt if credenticals are applicable to
*   any realm. 
*   
*/
  
  
  
  No   revision
  No   revision
  1.12.2.1  +5 -5  

cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-11-03 Thread olegk
olegk   2003/11/03 15:21:08

  Modified:httpclient/src/java/org/apache/commons/httpclient Tag:
HTTPCLIENT_2_0_BRANCH HttpMethodBase.java
  Log:
  PR #24352 (NLTM Proxy and basic host authorization)
  
  Fixed the bug causing basic authentication via NLTM Proxy to fail
  
  Contributed by Oleg Kalnichevski
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.159.2.18 +8 -8  
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.17
  retrieving revision 1.159.2.18
  diff -u -r1.159.2.17 -r1.159.2.18
  --- HttpMethodBase.java   3 Nov 2003 22:40:29 -   1.159.2.17
  +++ HttpMethodBase.java   3 Nov 2003 23:21:08 -   1.159.2.18
  @@ -1080,7 +1080,7 @@
   
   // Discard status line
   this.statusLine = null;
  - this.connectionCloseForced = false;
  +this.connectionCloseForced = false;
   
   //write the request and read the response, will retry
   processRequest(state, conn);
  @@ -2535,17 +2535,17 @@
   realmsUsed.add(realm);
   }
   
  +removeRequestHeader(HttpAuthenticator.WWW_AUTH_RESP);
  +removeRequestHeader(HttpAuthenticator.PROXY_AUTH_RESP);
   try {
   //remove preemptive header and reauthenticate
   switch (statusCode) {
   case HttpStatus.SC_UNAUTHORIZED:
  -removeRequestHeader(HttpAuthenticator.WWW_AUTH_RESP);
   authenticated = HttpAuthenticator.authenticate(
   authscheme, this, conn, state);
   this.realm = authscheme.getRealm();
   break;
   case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
  -removeRequestHeader(HttpAuthenticator.PROXY_AUTH_RESP);
   authenticated = HttpAuthenticator.authenticateProxy(
   authscheme, this, conn, state);
   this.proxyRealm = authscheme.getRealm();
  @@ -2754,7 +2754,7 @@
   responseConnection.close();
   }
   }
  - this.connectionCloseForced = false;
  +this.connectionCloseForced = false;
   doneWithConnection = true;
   if (!inExecute) {
   ensureConnectionRelease();
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-10-21 Thread olegk
olegk   2003/10/21 13:13:28

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Fixed NPE in HttpMethodBase#responseBodyConsumed()
  
  Reported by Tim McCune
  
  Contributed by Oleg Kalnichevski
  Reviewed by Michael Becke
  
  Revision  ChangesPath
  1.185 +9 -8  
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.184
  retrieving revision 1.185
  diff -u -r1.184 -r1.185
  --- HttpMethodBase.java   20 Oct 2003 22:17:12 -  1.184
  +++ HttpMethodBase.java   21 Oct 2003 20:13:28 -  1.185
  @@ -2230,12 +2230,13 @@
   // make sure this is the initial invocation of the notification,
   // ignore subsequent ones.
   responseStream = null;
  -responseConnection.setLastResponseInputStream(null);
  +if (responseConnection != null) {
  +responseConnection.setLastResponseInputStream(null);
   
  -if (shouldCloseConnection(responseConnection)) {
  -responseConnection.close();
  +if (shouldCloseConnection(responseConnection)) {
  +responseConnection.close();
  +}
   }
  -
   ensureConnectionRelease();
   }
   
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-10-21 Thread olegk
olegk   2003/10/21 13:15:03

  Modified:httpclient/src/java/org/apache/commons/httpclient Tag:
HTTPCLIENT_2_0_BRANCH HttpMethodBase.java
  Log:
  Fixed NPE in HttpMethodBase#responseBodyConsumed()
  
  Reported by Tim McCune
  
  Contributed by Oleg Kalnichevski
  Reviewed by Michael Becke
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.159.2.16 +9 -8  
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.15
  retrieving revision 1.159.2.16
  diff -u -r1.159.2.15 -r1.159.2.16
  --- HttpMethodBase.java   19 Oct 2003 18:49:56 -  1.159.2.15
  +++ HttpMethodBase.java   21 Oct 2003 20:15:03 -  1.159.2.16
  @@ -2739,12 +2739,13 @@
   // make sure this is the initial invocation of the notification,
   // ignore subsequent ones.
   responseStream = null;
  -responseConnection.setLastResponseInputStream(null);
  +if (responseConnection != null) {
  +responseConnection.setLastResponseInputStream(null);
   
  -if (shouldCloseConnection(responseConnection)) {
  -responseConnection.close();
  +if (shouldCloseConnection(responseConnection)) {
  +responseConnection.close();
  +}
   }
  -
   doneWithConnection = true;
   if (!inExecute) {
   ensureConnectionRelease();
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-10-13 Thread mbecke
mbecke  2003/10/13 05:19:22

  Modified:httpclient/src/java/org/apache/commons/httpclient Tag:
HTTPCLIENT_2_0_BRANCH HttpMethodBase.java
  Log:
  Adds some logging.
  
  Submitted by: Oleg Kalnichevski
  Reviewed by: Michael Becke
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.159.2.14 +10 -6 
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.13
  retrieving revision 1.159.2.14
  diff -u -r1.159.2.13 -r1.159.2.14
  --- HttpMethodBase.java   12 Oct 2003 04:02:20 -  1.159.2.13
  +++ HttpMethodBase.java   13 Oct 2003 12:19:22 -  1.159.2.14
  @@ -868,12 +868,15 @@
   /**
* Sets whether or not the connection should be force-closed when no longer 
* needed. This value should only be set to codetrue/code in abnormal 
  - * circumstances. 
  + * circumstances, such as HTTP protocol violations. 
* 
* @param b codetrue/code if the connection must be closed, 
codefalse/code
* otherwise.
*/
   protected void setConnectionCloseForced(boolean b) {
  +if (LOG.isDebugEnabled()) {
  +LOG.debug(Force-close connection:  + b);
  +}
   this.connectionCloseForced = b;
   }
   
  @@ -2053,7 +2056,7 @@
   }
   }
   } else {
  -if (isStrictMode()  LOG.isWarnEnabled()) {
  +if (LOG.isWarnEnabled()) {
   LOG.warn(Transfer-Encoding is set but does not contain 
\chunked\: 
   + transferEncoding);
   }
  @@ -2066,6 +2069,7 @@
   int expectedLength = getResponseContentLength();
   if (expectedLength == -1) {
   if (canResponseHaveBody(statusLine.getStatusCode())) {
  +LOG.warn(Response content length is not known);
   setConnectionCloseForced(true);
   result = is;
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-10-13 Thread mbecke
mbecke  2003/10/13 05:22:24

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Adds some logging.
  
  Submitted by: Oleg Kalnichevski
  Reviewed by: Michael Becke
  
  Revision  ChangesPath
  1.182 +9 -5  
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.181
  retrieving revision 1.182
  diff -u -r1.181 -r1.182
  --- HttpMethodBase.java   3 Oct 2003 20:57:35 -   1.181
  +++ HttpMethodBase.java   13 Oct 2003 12:22:24 -  1.182
  @@ -859,12 +859,15 @@
   /**
* Sets whether or not the connection should be force-closed when no longer 
* needed. This value should only be set to codetrue/code in abnormal 
  - * circumstances. 
  + * circumstances, such as HTTP protocol violations. 
* 
* @param b codetrue/code if the connection must be closed, 
codefalse/code
* otherwise.
*/
   protected void setConnectionCloseForced(boolean b) {
  +if (LOG.isDebugEnabled()) {
  +LOG.debug(Force-close connection:  + b);
  +}
   this.connectionCloseForced = b;
   }
   
  @@ -1728,6 +1731,7 @@
   long expectedLength = getResponseContentLength();
   if (expectedLength == -1) {
   if (canResponseHaveBody(statusLine.getStatusCode())) {
  +LOG.warn(Response content length is not known);
   setConnectionCloseForced(true);
   result = is;
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-09-02 Thread mbecke
mbecke  2003/09/02 19:17:50

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Fixes connection release when responseStream.close() throws an exception.
  PR: 22841
  Submitted by: Michael Becke
  Reviewed by: Ortwin GlŸck
  
  Revision  ChangesPath
  1.178 +6 -5  
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.177
  retrieving revision 1.178
  diff -u -r1.177 -r1.178
  --- HttpMethodBase.java   12 Aug 2003 02:55:22 -  1.177
  +++ HttpMethodBase.java   3 Sep 2003 02:17:49 -   1.178
  @@ -1075,7 +1075,8 @@
   // FYI - this may indirectly invoke responseBodyConsumed.
   responseStream.close();
   } catch (IOException e) {
  -// attempting cleanup, don't care about exception.
  +// the connection may not have been released, let's make sure
  +ensureConnectionRelease();
   }
   } else {
   // Make sure the connection has been released. If the response 
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-09-02 Thread mbecke
mbecke  2003/09/02 19:21:25

  Modified:httpclient/src/java/org/apache/commons/httpclient Tag:
HTTPCLIENT_2_0_BRANCH HttpMethodBase.java
  Log:
  Fixes connection release when responseStream.close() throws an exception.
  PR: 22841
  Submitted by: Michael Becke
  Reviewed by: Ortwin GlŸck
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.159.2.9 +6 -5  
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.8
  retrieving revision 1.159.2.9
  diff -u -r1.159.2.8 -r1.159.2.9
  --- HttpMethodBase.java   12 Aug 2003 18:45:03 -  1.159.2.8
  +++ HttpMethodBase.java   3 Sep 2003 02:21:24 -   1.159.2.9
  @@ -1322,7 +1322,8 @@
   // FYI - this may indirectly invoke responseBodyConsumed.
   responseStream.close();
   } catch (IOException e) {
  -// attempting cleanup, don't care about exception.
  +// the connection may not have been released, let's make sure
  +ensureConnectionRelease();
   }
   } else {
   // Make sure the connection has been released. If the response 
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-08-14 Thread olegk
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  ChangesPath
  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 -  1.159.2.7
  +++ HttpMethodBase.java   12 Aug 2003 18:45:03 -  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]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java HeaderGroup.java HttpMethod.java

2003-08-14 Thread mbecke
mbecke  2003/08/11 19:55:22

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java HeaderGroup.java
HttpMethod.java
  Log:
  Javadoc enhancements.
  PR: 22073
  Submitted by: Laura Werner
  Reviewed by: Michael Becke
  
  Revision  ChangesPath
  1.177 +13 -7 
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.176
  retrieving revision 1.177
  diff -u -r1.176 -r1.177
  --- HttpMethodBase.java   12 Aug 2003 02:35:17 -  1.176
  +++ HttpMethodBase.java   12 Aug 2003 02:55:22 -  1.177
  @@ -783,8 +783,11 @@
* Gets the response footer associated with the given name.
* Footer name matching is case insensitive.
* ttnull/tt will be returned if either ifooterName/i is
  - * ttnull/tt or there is no matching header for ifooterName/i
  - * or there are no footers available.
  + * ttnull/tt or there is no matching footer for ifooterName/i
  + * or there are no footers available.  If there are multiple footers
  + * with the same name, there values will be combined with the ',' separator
  + * as specified by RFC2616.
  + * 
* @param footerName the footer name to match
* @return the matching footer
*/
  @@ -805,7 +808,10 @@
   }
   
   /**
  - * Returns the current response stream
  + * Returns a stream from which the body of the current response may be read.
  + * If the method has not yet been executed, if coderesponseBodyConsumed/code
  + * has been called, or if the stream returned by a previous call has been 
closed,
  + * codenull/code will be returned.
*
* @return the current response stream
*/
  
  
  
  1.4   +4 -4  
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HeaderGroup.java
  
  Index: HeaderGroup.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HeaderGroup.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HeaderGroup.java  6 Apr 2003 22:31:52 -   1.3
  +++ HeaderGroup.java  12 Aug 2003 02:55:22 -  1.4
  @@ -132,7 +132,7 @@
   /**
* Gets a header representing all of the header values with the given name.
* If more that one header with the given name exists the values will be
  - * combined with a , as per RFC 1945.
  + * combined with a , as per RFC 2616.
* 
* pHeader name comparison is case insensitive.
* 
  
  
  
  1.28  +141 -57   
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethod.java
  
  Index: HttpMethod.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethod.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- HttpMethod.java   12 Aug 2003 02:35:17 -  1.27
  +++ HttpMethod.java   12 Aug 2003 02:55:22 -  1.28
  @@ -94,7 +94,9 @@
   String getName();
   
   /**
  - * Gets the host configuration for this method.
  + * Gets the host configuration for this method.  The configuration specifies
  + * the server, port, protocol, and proxy server via which this method will
  + * send its HTTP request. 
* 
* @return the HostConfiguration or codenull/code if none is set
*/
  @@ -105,8 +107,8 @@
* It is responsibility of the caller to ensure that the path is
* properly encoded (URL safe).
* 
  - * @param path the path of the HTTP method. The path is expected
  - *to be URL-encoded
  + * @param path The path of the HTTP method. The path is expected
  + * to be URL encoded.
*/
   void setPath(String path);
   
  @@ -117,15 +119,15 @@
* return the emactual/em path, following any redirects automatically
* handled by this HTTP method.
* 
  - * @return the path of the HTTP method
  + * @return the path of the HTTP method, in URL encoded form
*/
   String getPath();
   
   /**
  - * Gets the URI for this method. The URI will be absolute if the host
  - * configuration has been set or relative otherwise.
  + * Returns the URI for this method. The URI will be absolute if the host
  + * configuration has been set and relative otherwise.
* 
  - * @return URI 
  + * @return the URI for this method
* 
* @throws URIException if a URI cannot be constructed
   

cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-07-10 Thread mbecke
mbecke  2003/07/10 18:07:30

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  One more try at handling non chunked transfer encodings.
  PR: 21378
  Submitted by: Oleg Kalnichevski
  Reviewed by: Michael Becke
  
  Revision  ChangesPath
  1.164 +19 -21
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.163
  retrieving revision 1.164
  diff -u -r1.163 -r1.164
  --- HttpMethodBase.java   8 Jul 2003 21:59:18 -   1.163
  +++ HttpMethodBase.java   11 Jul 2003 01:07:29 -  1.164
  @@ -71,6 +71,7 @@
   import java.util.BitSet;
   import java.util.HashSet;
   import java.util.Set;
  +
   import org.apache.commons.httpclient.auth.AuthScheme;
   import org.apache.commons.httpclient.auth.AuthenticationException;
   import org.apache.commons.httpclient.auth.HttpAuthenticator;
  @@ -2041,26 +2042,23 @@
   is = new WireLogInputStream(is);
   }
   InputStream result = null;
  -Header[] transferEncodingHeaders = 
responseHeaders.getHeaders(Transfer-Encoding);
  +Header transferEncodingHeader = 
responseHeaders.getFirstHeader(Transfer-Encoding);
   // We use Transfer-Encoding if present and ignore Content-Length.
   // RFC2616, 4.4 item number 3
  -if (transferEncodingHeaders.length  0) {
  -boolean containsChunked = false;
  -for (int i = 0; i  transferEncodingHeaders.length; i++) {
  -String encoding = transferEncodingHeaders[i].getValue();
  -if (chunked.equalsIgnoreCase(encoding)) {
  -containsChunked = true;
  -break;
  -} else if (identity.equalsIgnoreCase(encoding)) {
  -//No content transformation needed
  -} else {
  -if (LOG.isWarnEnabled()) {
  -LOG.warn(Unsupported transfer encoding:  + encoding);
  -}
  +if (transferEncodingHeader != null) {
  +
  +String transferEncoding = transferEncodingHeader.getValue();
  +if (!chunked.equalsIgnoreCase(transferEncoding) 
  + !identity.equalsIgnoreCase(transferEncoding)) {
  +if (LOG.isWarnEnabled()) {
  +LOG.warn(Unsupported transfer encoding:  + transferEncoding);
   }
   }
  -if (containsChunked) {
  -// Some HTTP servers do not bother sending a closing chunk 
  +HeaderElement[] encodings = transferEncodingHeader.getValues();
  +// The chunked encoding must be the last one applied
  +// RFC2616, 14.41
  +int len = encodings.length;
  +if ((len  0)  (chunked.equalsIgnoreCase(encodings[len - 
1].getName( { 
   // if response body is empty
   if (conn.isResponseAvailable(conn.getSoTimeout())) {
   result = new ChunkedInputStream(is, this);
  @@ -2074,7 +2072,7 @@
   } else {
   if (isStrictMode()  LOG.isWarnEnabled()) {
   LOG.warn(Transfer-Encoding is set but does not contain 
\chunked\: 
  -+ getResponseHeader(Transfer-Encoding));
  ++ transferEncoding);
   }
   // The connection must be terminated by closing 
   // the socket as per RFC 2616, 3.6
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-07-08 Thread olegk
olegk   2003/07/08 14:24:38

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Force-close connection feature added. Follow-up to bug #21378
  
  Contributed by Michael Becke  Oleg Kalnichevski
  
  Revision  ChangesPath
  1.162 +38 -10
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.161
  retrieving revision 1.162
  diff -u -r1.161 -r1.162
  --- HttpMethodBase.java   8 Jul 2003 11:51:45 -   1.161
  +++ HttpMethodBase.java   8 Jul 2003 21:24:37 -   1.162
  @@ -258,6 +258,9 @@
   /** true if we are finished with the connection */
   private boolean doneWithConnection = false;
   
  +/** true if the connection must be dropped */
  +private boolean forceCloseConnection = false;
  +
   /** Number of milliseconds to wait for 100-contunue response. */
   private static final int RESPONSE_WAIT_TIME_MS = 3000;
   
  @@ -843,6 +846,30 @@
   }
   
   /**
  + * Return tttrue/tt if the connection must be dropped due to some 
  + * abnormal circumstances, ttfalse/tt if normal decision
  + * process should take place.
  + * 
  + * @return tttrue/tt if the connection must be dropped.
  + */
  +protected boolean getForceCloseConnection() {
  +return this.forceCloseConnection;
  +}
  +
  +/**
  + * Set to tttrue/tt if the connection must be dropped due to some 
  + * abnormal circumstances. Set to ttfalse/tt if normal decision
  + * process should take place.
  + * 
  + * @param b tttrue/tt if the connection must be dropped, ttfalse/tt
  + * otherwise.
  + */
  +protected void setForceCloseConnection(boolean b) {
  +this.forceCloseConnection = b;
  +}
  +
  +
  +/**
* Return true if we should close the connection now.  The connection will
* only be left open if we are using HTTP1.1 or if Connection: keep-alive 
* was sent.
  @@ -853,11 +880,9 @@
*/
   protected boolean shouldCloseConnection(HttpConnection conn) {
   
  -// if we are not chunked and there is no content length the connection
  -// cannot be reused
  -if (responseHeaders.getFirstHeader(Transfer-Encoding) == null 
  - getResponseContentLength()  0) {
  -LOG.debug(Should close connection as content-length is missing.);
  +// Connection must be closed due to an abnormal circumstance 
  +if (getForceCloseConnection()) {
  +LOG.debug(Should forcefully close connection.);
   return true;
   }
   
  @@ -1268,6 +1293,7 @@
   recoverableExceptionCount = 0;
   inExecute = false;
   doneWithConnection = false;
  +forceCloseConnection = false;
   }
   
   /**
  @@ -2053,14 +2079,16 @@
   LOG.warn(Transfer-Encoding is set but does not contain 
\chunked\: 
   + getResponseHeader(Transfer-Encoding));
   }
  -// we assume that the response connection will be terminated by 
closing 
  +// The connection must be terminated by closing 
   // the socket as per RFC 2616, 3.6
  +setForceCloseConnection(true);
   result = is;  
   }
   } else {
   int expectedLength = getResponseContentLength();
   if (expectedLength == -1) {
   if (canResponseHaveBody(statusLine.getStatusCode())) {
  +setForceCloseConnection(true);
   result = is;
   }
   } else {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-07-08 Thread olegk
olegk   2003/07/08 14:59:18

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Adds a feature to force-close connection in abnormal circumstances. Follow up to bug 
fix #21378
  (corrects the previous patch apllied by mistake)
  
  Contributed by Michael Becke  Oleg Kalnichevski
  
  Revision  ChangesPath
  1.163 +16 -19
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.162
  retrieving revision 1.163
  diff -u -r1.162 -r1.163
  --- HttpMethodBase.java   8 Jul 2003 21:24:37 -   1.162
  +++ HttpMethodBase.java   8 Jul 2003 21:59:18 -   1.163
  @@ -258,8 +258,8 @@
   /** true if we are finished with the connection */
   private boolean doneWithConnection = false;
   
  -/** true if the connection must be dropped */
  -private boolean forceCloseConnection = false;
  +/** true if the connection must be closed when no longer needed */
  +private boolean connectionCloseForced = false;
   
   /** Number of milliseconds to wait for 100-contunue response. */
   private static final int RESPONSE_WAIT_TIME_MS = 3000;
  @@ -846,29 +846,26 @@
   }
   
   /**
  - * Return tttrue/tt if the connection must be dropped due to some 
  - * abnormal circumstances, ttfalse/tt if normal decision
  - * process should take place.
  + * Tests if the connection should be force-closed when no longer needed.
* 
  - * @return tttrue/tt if the connection must be dropped.
  + * @return codetrue/code if the connection must be closed
*/
  -protected boolean getForceCloseConnection() {
  -return this.forceCloseConnection;
  +protected boolean isConnectionCloseForced() {
  +return this.connectionCloseForced;
   }
   
   /**
  - * Set to tttrue/tt if the connection must be dropped due to some 
  - * abnormal circumstances. Set to ttfalse/tt if normal decision
  - * process should take place.
  + * Sets whether or not the connection should be force-closed when no longer 
  + * needed. This value should only be set to codetrue/code in abnormal 
  + * circumstances. 
* 
  - * @param b tttrue/tt if the connection must be dropped, ttfalse/tt
  + * @param b codetrue/code if the connection must be closed, 
codefalse/code
* otherwise.
*/
  -protected void setForceCloseConnection(boolean b) {
  -this.forceCloseConnection = b;
  +protected void setConnectionCloseForced(boolean b) {
  +this.connectionCloseForced = b;
   }
   
  -
   /**
* Return true if we should close the connection now.  The connection will
* only be left open if we are using HTTP1.1 or if Connection: keep-alive 
  @@ -881,7 +878,7 @@
   protected boolean shouldCloseConnection(HttpConnection conn) {
   
   // Connection must be closed due to an abnormal circumstance 
  -if (getForceCloseConnection()) {
  +if (isConnectionCloseForced()) {
   LOG.debug(Should forcefully close connection.);
   return true;
   }
  @@ -1293,7 +1290,7 @@
   recoverableExceptionCount = 0;
   inExecute = false;
   doneWithConnection = false;
  -forceCloseConnection = false;
  +connectionCloseForced = false;
   }
   
   /**
  @@ -2081,14 +2078,14 @@
   }
   // The connection must be terminated by closing 
   // the socket as per RFC 2616, 3.6
  -setForceCloseConnection(true);
  +setConnectionCloseForced(true);
   result = is;  
   }
   } else {
   int expectedLength = getResponseContentLength();
   if (expectedLength == -1) {
   if (canResponseHaveBody(statusLine.getStatusCode())) {
  -setForceCloseConnection(true);
  +setConnectionCloseForced(true);
   result = is;
   }
   } else {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-07-08 Thread olegk
olegk   2003/07/08 15:05:25

  Modified:httpclient/src/java/org/apache/commons/httpclient Tag:
HTTPCLIENT_2_0_BRANCH HttpMethodBase.java
  Log:
  Adds a feature to force-close connection in abnormal circumstances. Follow up to bug 
fix #21378
  
  Contributed by Michael Becke  Oleg Kalnichevski
  
  Revision  ChangesPath
  No   revision
  
  
  No   revision
  
  
  1.159.2.2 +35 -10
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.1
  retrieving revision 1.159.2.2
  diff -u -r1.159.2.1 -r1.159.2.2
  --- HttpMethodBase.java   8 Jul 2003 11:47:15 -   1.159.2.1
  +++ HttpMethodBase.java   8 Jul 2003 22:05:25 -   1.159.2.2
  @@ -258,6 +258,9 @@
   /** true if we are finished with the connection */
   private boolean doneWithConnection = false;
   
  +/** true if the connection must be closed when no longer needed */
  +private boolean connectionCloseForced = false;
  +
   /** Number of milliseconds to wait for 100-contunue response. */
   private static final int RESPONSE_WAIT_TIME_MS = 3000;
   
  @@ -843,6 +846,27 @@
   }
   
   /**
  + * Tests if the connection should be force-closed when no longer needed.
  + * 
  + * @return codetrue/code if the connection must be closed
  + */
  +protected boolean isConnectionCloseForced() {
  +return this.connectionCloseForced;
  +}
  +
  +/**
  + * Sets whether or not the connection should be force-closed when no longer 
  + * needed. This value should only be set to codetrue/code in abnormal 
  + * circumstances. 
  + * 
  + * @param b codetrue/code if the connection must be closed, 
codefalse/code
  + * otherwise.
  + */
  +protected void setConnectionCloseForced(boolean b) {
  +this.connectionCloseForced = b;
  +}
  +
  +/**
* Return true if we should close the connection now.  The connection will
* only be left open if we are using HTTP1.1 or if Connection: keep-alive 
* was sent.
  @@ -853,11 +877,9 @@
*/
   protected boolean shouldCloseConnection(HttpConnection conn) {
   
  -// if we are not chunked and there is no content length the connection
  -// cannot be reused
  -if (responseHeaders.getFirstHeader(Transfer-Encoding) == null 
  - getResponseContentLength()  0) {
  -LOG.debug(Should close connection as content-length is missing.);
  +// Connection must be closed due to an abnormal circumstance 
  +if (isConnectionCloseForced()) {
  +LOG.debug(Should forcefully close connection.);
   return true;
   }
   
  @@ -1268,6 +1290,7 @@
   recoverableExceptionCount = 0;
   inExecute = false;
   doneWithConnection = false;
  +connectionCloseForced = false;
   }
   
   /**
  @@ -2053,14 +2076,16 @@
   LOG.warn(Transfer-Encoding is set but does not contain 
\chunked\: 
   + getResponseHeader(Transfer-Encoding));
   }
  -// we assume that the response connection will be terminated by 
closing 
  +// The connection must be terminated by closing 
   // the socket as per RFC 2616, 3.6
  +setConnectionCloseForced(true);
   result = is;  
   }
   } else {
   int expectedLength = getResponseContentLength();
   if (expectedLength == -1) {
   if (canResponseHaveBody(statusLine.getStatusCode())) {
  +setConnectionCloseForced(true);
   result = is;
   }
   } else {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-07-05 Thread olegk
olegk   2003/07/05 11:30:27

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  References to the version number updated. New version number: 2.1-m1
  
  Revision  ChangesPath
  1.160 +5 -5  
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
  retrieving revision 1.160
  diff -u -r1.159 -r1.160
  --- HttpMethodBase.java   2 Jul 2003 01:28:49 -   1.159
  +++ HttpMethodBase.java   5 Jul 2003 18:30:27 -   1.160
  @@ -155,7 +155,7 @@
   static {
   String agent = System.getProperties()
.getProperty(httpclient.useragent,
  -  Jakarta Commons-HttpClient/2.0beta2);
  +  Jakarta Commons-HttpClient/2.1m1);
   USER_AGENT = new Header(User-Agent, agent);
   }
   
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-06-27 Thread olegk
olegk   2003/06/27 14:17:37

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Javadocs corrections
  
  Contributed by Gary Gregory [EMAIL PROTECTED]  Oleg Kalnichevski
  
  Revision  ChangesPath
  1.157 +17 -18
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.156
  retrieving revision 1.157
  diff -u -r1.156 -r1.157
  --- HttpMethodBase.java   23 Jun 2003 23:41:39 -  1.156
  +++ HttpMethodBase.java   27 Jun 2003 21:17:36 -  1.157
  @@ -135,6 +135,7 @@
* @author Michael Becke
* @author a href=mailto:[EMAIL PROTECTED]Oleg Kalnichevski/a
* @author a href=mailto:[EMAIL PROTECTED]Mike Bowler/a
  + * @author a href=mailto:[EMAIL PROTECTED]Gary Gregory/a
*
* @version $Revision$ $Date$
*/
  @@ -231,10 +232,10 @@
   /** Whether or not I should automatically process authentication. */
   private boolean doAuthentication = true;
   
  -/** Whether or not I should use the HTTP/1.1 protocol. */
  +/** Whether or not I should use the HTTP/1.1 protocol. The default is 
tttrue/tt. */
   private boolean http11 = true;
   
  -/** True if we're in strict mode. */
  +/** True if we're in strict mode. The default is ttfalse/tt. */
   private boolean strictMode = false;
   
   /** Whether or not I have been executed. */
  @@ -257,7 +258,7 @@
   /** true if we are finished with the connection */
   private boolean doneWithConnection = false;
   
  -/** Number of milliseconds to wait for 100-contunue response */
  +/** Number of milliseconds to wait for 100-contunue response. */
   private static final int RESPONSE_WAIT_TIME_MS = 3000;
   
   // --- Constructors
  @@ -416,7 +417,7 @@
   
   /**
* Access to flag to determine if client should use
  - * HTTP/1.1 protocol.
  + * HTTP/1.1 protocol. The default is tttrue/tt. 
*
* @return tttrue/tt if I should use the HTTP/1.1 protocol
*/
  @@ -809,13 +810,12 @@
   }
   
   /**
  - * Turns strict mode on or off.  In strict mode (the default) we following
  - * the letter of RFC 2616, the Http 1.1 specification. If strict mode is
  - * turned off we attempt to violate the specification in the same way that
  - * most Http user agent's do (and many HTTP servers expect. NOTE:
  - * StrictMode is currently experimental and its functionlaity may change
  - * in the future.
  - *
  + * Defines how strictly HttpClient follows the HTTP protocol specification  
  + * (RFC 2616 and other relevant RFCs). In the strict mode HttpClient precisely
  + * implements the requirements of the specification, whereas in non-strict mode 
  + * it attempts to mimic the exact behaviour of commonly used HTTP agents, 
  + * which many HTTP servers expect.
  + * 
* @param strictMode true for strict mode, false otherwise
*/
   public void setStrictMode(boolean strictMode) {
  @@ -823,9 +823,8 @@
   }
   
   /**
  - * Returns the value of strictMode. NOTE:  StrictMode is currently
  - * experimental and its functionlaity may  change in the future.
  - *
  + * Returns the value of strictMode.
  + * 
* @return true if strict mode is enabled.
*/
   public boolean isStrictMode() {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-06-27 Thread adrian
adrian  2003/06/27 18:38:43

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Changed HttpMethodBase to initialize its Log object with HttpMethodBase.class 
instead of HttpMethod.class.
  
  PR: Bug 21159
  Submitted by: Laura Werner
  Reviewed by:  Adrian Sutton
  
  Revision  ChangesPath
  1.158 +5 -5  
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.157
  retrieving revision 1.158
  diff -u -r1.157 -r1.158
  --- HttpMethodBase.java   27 Jun 2003 21:17:36 -  1.157
  +++ HttpMethodBase.java   28 Jun 2003 01:38:43 -  1.158
  @@ -147,7 +147,7 @@
   // -- Constants
   
   /** Log object for this class. */
  -private static final Log LOG = LogFactory.getLog(HttpMethod.class);
  +private static final Log LOG = LogFactory.getLog(HttpMethodBase.class);
   
   /** The User-Agent header sent on every request. */
   protected static final Header USER_AGENT;
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-06-20 Thread adrian
adrian  2003/06/20 06:30:02

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Avoids a SocketException being thrown when the Content-Length header is missing.
  
  PR: bug 20938
  
  Reviewed by:  Michael Becke and Oleg Kalnichevski
  CVS: --
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  ChangesPath
  1.153 +12 -4 
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.152
  retrieving revision 1.153
  diff -u -r1.152 -r1.153
  --- HttpMethodBase.java   13 Jun 2003 21:32:17 -  1.152
  +++ HttpMethodBase.java   20 Jun 2003 13:30:02 -  1.153
  @@ -880,6 +880,14 @@
*/
   protected boolean shouldCloseConnection(HttpConnection conn) {
   
  +// if we are not chunked and there is no content length the connection
  +// cannot be reused
  +if (responseHeaders.getFirstHeader(Transfer-Encoding) == null 
  + getResponseContentLength()  0) {
  +LOG.debug(Should close connection as content-length is missing.);
  +return true;
  +}
  +
   Header connectionHeader = null;
   // In case being connected via a proxy server
   if (!conn.isTransparent()) {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-06-20 Thread olegk
olegk   2003/06/20 09:30:59

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Code optimization
  
  Contributed by Oleg Kalnichevski
  Reviewed by Mike Becke
  
  Revision  ChangesPath
  1.154 +6 -29 
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.153
  retrieving revision 1.154
  diff -u -r1.153 -r1.154
  --- HttpMethodBase.java   20 Jun 2003 13:30:02 -  1.153
  +++ HttpMethodBase.java   20 Jun 2003 16:30:58 -  1.154
  @@ -676,34 +676,11 @@
   }
   for (int i = headers.length - 1; i = 0; i++) {
   Header header = headers[i];
  -String lengthValue = null;
  -// we're using this just in case the content length is duplicated
  -// i.e. '57, 57'
   try {
  -HeaderElement[] lengthElements = header.getValues();
  -
  -if (lengthElements.length  1) {
  -// looks like the content length header was duplicated. if so
  -// they won't be key=value pairs so we just want to get
  -// the name not the value (which should be null)
  -// take the first value and ignore any others
  -lengthValue = lengthElements[0].getName();
  -} else {
  -lengthValue = header.getValue();
  -}
  -} catch (HttpException e) {
  +return Integer.parseInt(header.getValue());
  +} catch (NumberFormatException e) {
   if (LOG.isWarnEnabled()) {
   LOG.warn(Invalid content-length value:  + e.getMessage());
  -}
  -lengthValue = null;
  -}
  -if (lengthValue != null) {
  -try {
  -return Integer.parseInt(lengthValue);
  -} catch (NumberFormatException e) {
  -if (LOG.isWarnEnabled()) {
  -LOG.warn(Invalid content-length value:  + e.getMessage());
  -}
   }
   }
   // See if we can have better luck with another header, if present
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-06-20 Thread olegk
olegk   2003/06/20 09:43:19

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Bug fix #20942 (Request with DIGEST authentication fails when redirected)
  
  Contributed by Oleg Kalnichevski
  Reviewed by Mike Becke
  
  Revision  ChangesPath
  1.155 +7 -5  
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.154
  retrieving revision 1.155
  diff -u -r1.154 -r1.155
  --- HttpMethodBase.java   20 Jun 2003 16:30:58 -  1.154
  +++ HttpMethodBase.java   20 Jun 2003 16:43:18 -  1.155
  @@ -1152,7 +1152,9 @@
   }
   
   //invalidate the list of authentication attempts
  -this.realms.clear(); 
  +this.realms.clear();
  +//remove exisitng authentication headers
  +removeRequestHeader(HttpAuthenticator.WWW_AUTH_RESP); 
   //update the current location with the redirect location.
   //avoiding use of URL.getPath() and URL.getQuery() to keep
   //jdk1.2 comliance.
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java StatusLine.java

2003-03-31 Thread mbecke
mbecke  2003/03/31 16:25:24

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java StatusLine.java
  Log:
  Adds support for unusual HTTP status line returned by some servers.
  
  PR: 18439
  Reviewed by: Jeff Dever and Oleg Kalnichevski
  
  Revision  ChangesPath
  1.127 +12 -6 
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.126
  retrieving revision 1.127
  diff -u -r1.126 -r1.127
  --- HttpMethodBase.java   27 Mar 2003 20:58:27 -  1.126
  +++ HttpMethodBase.java   1 Apr 2003 00:25:24 -   1.127
  @@ -2000,7 +2000,10 @@
   
   //read out the HTTP status string
   String statusString = conn.readLine();
  -while ((statusString != null)  !statusString.startsWith(HTTP/)) {
  +while ((statusString != null)  !statusString.startsWith(HTTP)) {
  +if (Wire.enabled()) {
  +Wire.input(statusString + \r\n);
  +}
   statusString = conn.readLine();
   }
   if (statusString == null) {
  @@ -2008,7 +2011,7 @@
   // response.  Try again.
   throw new HttpRecoverableException(Error in parsing the status 
   +  line from the response: unable to find line starting with
  -+  \HTTP/\);
  ++  \HTTP\);
   }
   if (Wire.enabled()) {
   Wire.input(statusString + \r\n);
  @@ -2022,6 +2025,9 @@
   http11 = false;
   } else if (httpVersion.equals(HTTP/1.1)) {
   http11 = true;
  +} else if (httpVersion.equals(HTTP)) {
  +// some servers do not specify the version correctly, we will just 
assume 1.0
  +http11 = false;
   } else {
   throw new HttpException(Unrecognized server protocol: '
   + httpVersion + ');
  
  
  
  1.9   +6 -6  
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/StatusLine.java
  
  Index: StatusLine.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/StatusLine.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- StatusLine.java   30 Jan 2003 05:01:54 -  1.8
  +++ StatusLine.java   1 Apr 2003 00:25:24 -   1.9
  @@ -121,9 +121,9 @@
   
   
   //check validity of the Status-Line
  -if (!statusLine.startsWith(HTTP/)) {
  +if (!statusLine.startsWith(HTTP)) {
   throw new HttpException(Status-Line ' + statusLine 
  -+ ' does not start with HTTP/);
  ++ ' does not start with HTTP);
   }
   
   //handle the HTTP-Version
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-03-26 Thread mbecke
mbecke  2003/03/26 19:53:08

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  The redirect request is now processed with URI instead of URL.
  
  Reviewed by: Oleg Kalnichevski
  
  Revision  ChangesPath
  1.125 +52 -46
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.124
  retrieving revision 1.125
  diff -u -r1.124 -r1.125
  --- HttpMethodBase.java   24 Mar 2003 18:39:40 -  1.124
  +++ HttpMethodBase.java   27 Mar 2003 03:53:08 -  1.125
  @@ -68,14 +68,12 @@
   import java.io.IOException;
   import java.io.InputStream;
   import java.io.InterruptedIOException;
  -import java.net.MalformedURLException;
  -import java.net.URL;
   import java.util.HashSet;
   import java.util.Set;
   
  -import org.apache.commons.httpclient.cookie.MalformedCookieException;
   import org.apache.commons.httpclient.cookie.CookiePolicy;
   import org.apache.commons.httpclient.cookie.CookieSpec;
  +import org.apache.commons.httpclient.cookie.MalformedCookieException;
   import org.apache.commons.httpclient.protocol.Protocol;
   import org.apache.commons.httpclient.util.URIUtil;
   import org.apache.commons.logging.Log;
  @@ -128,7 +126,7 @@
* @author a href=mailto:[EMAIL PROTECTED]dIon Gillard/a
* @author a href=mailto:[EMAIL PROTECTED]Jeff Dever/a
* @author a href=mailto:[EMAIL PROTECTED]Davanum Srinivas/a
  - * @author Ortwin Glück
  + * @author Ortwin Gl�ck
* @author Eric Johnson
* @author Michael Becke
* @author a href=mailto:[EMAIL PROTECTED]Oleg Kalnichevski/a
  @@ -1074,33 +1072,37 @@
   
   //rfc2616 demands the location value be a complete URI
   //Location   = Location : absoluteURI
  -URL redirectUrl = null;
  -URL currentUrl = null;
  +URI redirectUri = null;
  +URI currentUri = null;
   
   try {
  -currentUrl = new URL(conn.getProtocol().getScheme(),
  -conn.getHost(), conn.getPort(), this.getPath());
  -redirectUrl = new URL(location);
  -} catch (MalformedURLException e) {
  -if (isStrictMode()) {
  -LOG.warn(Redirected location ' + location 
  -+ ' is not acceptable in strict mode);
  -return false;
  -} else { //location is incomplete, use current values for defaults
  -try {
  -LOG.debug(Redirect URL is not absolute - parsing as relative);
  -redirectUrl = new URL(currentUrl, location);
  -} catch (MalformedURLException ex) {
  -LOG.warn(Redirected location ' + location
  -+ ' is malformed);
  +currentUri = new URI(
  +conn.getProtocol().getScheme(),
  +null,
  +conn.getHost(), 
  +conn.getPort(), 
  +this.getPath()
  +);
  +redirectUri = new URI(location.toCharArray());
  +if (redirectUri.isRelativeURI()) {
  +if (isStrictMode()) {
  +LOG.warn(Redirected location ' + location 
  ++ ' is not acceptable in strict mode);
   return false;
  +} else { 
  +//location is incomplete, use current values for defaults
  +LOG.debug(Redirect URI is not absolute - parsing as relative);
  +redirectUri = new URI(currentUri, redirectUri);
   }
   }
  +} catch (URIException e) {
  +LOG.warn(Redirected location ' + location + ' is malformed);
  +return false;
   }
   
   //check for redirect to a different protocol, host or port
   try {
  -checkValidRedirect(currentUrl, redirectUrl);
  +checkValidRedirect(currentUri, redirectUri);
   } catch (HttpException ex) {
   //LOG the error and let the client handle the redirect
   LOG.warn(ex.getMessage());
  @@ -1110,51 +1112,56 @@
   //update the current location with the redirect location.
   //avoiding use of URL.getPath() and URL.getQuery() to keep
   //jdk1.2 comliance.
  -setPath(URIUtil.getPath(redirectUrl.toString()));
  -setQueryString(URIUtil.getQuery(redirectUrl.toString()));
  +setPath(redirectUri.getEscapedPath());
  +setQueryString(redirectUri.getEscapedQuery());
   
   if (LOG.isDebugEnabled()) {
  -LOG.debug(Redirecting from ' + currentUrl.toExternalForm()
  -

cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java ConnectMethod.java

2003-03-07 Thread mbecke
mbecke  2003/03/07 05:50:53

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java ConnectMethod.java
  Log:
  This should fix the problem where the ConnectMethod would prematurely release the 
connection.
  PR: 17563
  Reviewed by: Oleg and Jeff
  
  Revision  ChangesPath
  1.121 +6 -14 
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.120
  retrieving revision 1.121
  diff -u -r1.120 -r1.121
  --- HttpMethodBase.java   6 Mar 2003 07:49:03 -   1.120
  +++ HttpMethodBase.java   7 Mar 2003 13:50:52 -   1.121
  @@ -72,7 +72,6 @@
   import java.net.URL;
   import java.util.HashSet;
   import java.util.Set;
  -import java.util.StringTokenizer;
   
   import org.apache.commons.httpclient.cookie.MalformedCookieException;
   import org.apache.commons.httpclient.cookie.CookiePolicy;
  @@ -806,15 +805,8 @@
*/
   protected boolean shouldCloseConnection() {
   if (!http11) {
  -if (getName().equals(ConnectMethod.NAME) 
  - (statusLine.getStatusCode() == HttpStatus.SC_OK)) {
  -LOG.debug(Will leave connection open for tunneling);
  -return false;
  -} else {
  -LOG.debug(Should close connection since using HTTP/1.0,  
  -+ ConnectMethod and status is OK);
  -return true;
  -}
  +LOG.debug(Should close connection since using HTTP/1.0.);
  +return true;
   } else {
   Header connectionHeader = getResponseHeader(connection);
   if (null != connectionHeader
  
  
  
  1.8   +23 -4 
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ConnectMethod.java
  
  Index: ConnectMethod.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ConnectMethod.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ConnectMethod.java28 Jan 2003 04:40:20 -  1.7
  +++ ConnectMethod.java7 Mar 2003 13:50:53 -   1.8
  @@ -167,10 +167,29 @@
   conn.printLine(line);
   }
   
  +/**
  + * Does nothing.  This should be handled by the actual method.
  + * 
  + * @see HttpMethodBase#responseBodyConsumed()
  + */
  +protected void responseBodyConsumed() {
  +}
   
  +/**
  + * Returns codetrue/code if the status code is anything other than
  + * SC_OK, codefalse/code otherwise.
  + * 
  + * @see HttpMethodBase#shouldCloseConnection()
  + * @see HttpStatus#SC_OK
  + */
  +protected boolean shouldCloseConnection() {
  +return (getStatusCode() != HttpStatus.SC_OK);
  +}
  +
   /** Log object for this class. */
   private static final Log LOG = LogFactory.getLog(ConnectMethod.class);
   
   /** The wrapped method */
   private HttpMethod method;
  +
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java HttpClient.java

2003-02-21 Thread mbecke
mbecke  2003/02/21 05:48:09

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java HttpClient.java
  Log:
  Fixed a bug where an HttpConnection could be lost.  If an exception occurred between 
the point when a connection was retrieved and when is was assigned to a method the 
connection would be lost.
PR:
Obtained from: Sam Maloney
  
  Revision  ChangesPath
  1.115 +8 -5  
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.114
  retrieving revision 1.115
  diff -u -r1.114 -r1.115
  --- HttpMethodBase.java   18 Feb 2003 15:54:29 -  1.114
  +++ HttpMethodBase.java   21 Feb 2003 13:48:09 -  1.115
   -930,6 +930,10 
   
   LOG.trace(enter HttpMethodBase.execute(HttpState, HttpConnection));
   
  +// this is our connection now, assign it to a local variable so 
  +// that it can be released later
  +this.responseConnection = conn;
  +
   checkExecuteConditions(state, conn);
   inExecute = true;
   
   -946,7 +950,6 
   
   while (forwardCount++  MAX_FORWARDS) {
   // on every retry, reset this state information.
  -responseConnection = conn;
   conn.setLastResponseInputStream(null);
   
   if (LOG.isDebugEnabled()) {
  
  
  
  1.69  +25 -11
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java
  
  Index: HttpClient.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- HttpClient.java   28 Jan 2003 04:40:20 -  1.68
  +++ HttpClient.java   21 Feb 2003 13:48:09 -  1.69
   -84,6 +84,7 
* author Ortwin Glück
* author a href=mailto:[EMAIL PROTECTED]Michael Becke/a
* author a href=mailto:[EMAIL PROTECTED]Mike Bowler/a
  + * author Sam Maloney
* 
* version $Revision$ $Date$
*/
   -550,15 +551,28 
   httpConnectionTimeout
   );
   
  -method.setStrictMode(strictMode);
  +try {
  +// Catch all possible exceptions to make sure to release the 
  +// connection, as although the user may call 
  +// Method-releaseConnection(), the method doesn't know about the
  +// connection until HttpMethod.execute() is called.
  +
  +method.setStrictMode(strictMode);
   
  -if (!connection.isOpen()) {
  -connection.setSoTimeout(soTimeout);
  -connection.setConnectionTimeout(connectionTimeout);
  -connection.open();
  -if (connection.isProxied()  connection.isSecure()) {
  -method = new ConnectMethod(method);
  +if (!connection.isOpen()) {
  +connection.setSoTimeout(soTimeout);
  +connection.setConnectionTimeout(connectionTimeout);
  +connection.open();
  +if (connection.isProxied()  connection.isSecure()) {
  +method = new ConnectMethod(method);
  +}
   }
  +} catch (IOException e) {
  +connection.releaseConnection();
  +throw e;
  +} catch (RuntimeException e) {
  +connection.releaseConnection();
  +throw e;
   }
   
   return method.execute(state, connection);
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-02-16 Thread olegk
olegk   2003/02/16 09:56:17

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Changelog:
  
  - fix for inconsistent cookie rejection in HttpMethodBase#ParseResponseHeaders method
  
  Reported by by James Couball [EMAIL PROTECTED]
  Contributed by James Couball
  Reviewed by Oleg Kalnichevski
  
  Revision  ChangesPath
  1.113 +46 -36
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.112
  retrieving revision 1.113
  diff -u -r1.112 -r1.113
  --- HttpMethodBase.java   16 Feb 2003 13:08:32 -  1.112
  +++ HttpMethodBase.java   16 Feb 2003 17:56:17 -  1.113
  @@ -73,6 +73,7 @@
   import java.util.Set;
   import java.util.StringTokenizer;
   
  +import org.apache.commons.httpclient.cookie.MalformedCookieException;
   import org.apache.commons.httpclient.cookie.CookiePolicy;
   import org.apache.commons.httpclient.cookie.CookieSpec;
   import org.apache.commons.httpclient.util.URIUtil;
  @@ -1586,45 +1587,54 @@
   LOG.trace(enter HttpMethodBase.processResponseHeaders(HttpState, 
   + HttpConnection));
   
  -// add cookies, if any
  -// should we set cookies?
  -Header setCookieHeader = getResponseHeader(set-cookie2);
  -if (null == setCookieHeader) { //ignore old-style if new is supported
  -setCookieHeader = getResponseHeader(set-cookie);
  +Header[] headers = getResponseHeaderGroup().getHeaders(set-cookie2);
  +//Only process old style set-cookie headers if new style headres
  +//are not present
  +if (headers.length == 0) { 
  +headers = getResponseHeaderGroup().getHeaders(set-cookie);
   }
  -
  -if (setCookieHeader == null) { 
  -return;
  -}
  -try {
  -
  -CookieSpec parser = 
CookiePolicy.getSpecByPolicy(state.getCookiePolicy());
  -Cookie[] cookies = parser.parse(
  -  conn.getHost(),
  -  conn.getPort(),
  -  getPath(),
  -  conn.isSecure(),
  -  setCookieHeader);
  -for (int i = 0; i  cookies.length; i++) {
  -Cookie cookie = cookies[i];
  -parser.validate(
  +
  +CookieSpec parser = CookiePolicy.getSpecByPolicy(state.getCookiePolicy());
  +for (int i = 0; i  headers.length; i++) {
  +Header header = headers[i];
  +Cookie[] cookies = null;
  +try {
  +cookies = parser.parse(
 conn.getHost(),
 conn.getPort(),
 getPath(),
 conn.isSecure(),
  -  cookie);
  -if (LOG.isDebugEnabled()) {
  -LOG.debug(Cookie accepted: \ 
  -+ parser.formatCookie(cookie) + \);
  +  header);
  +} catch (MalformedCookieException e) {
  +if (LOG.isWarnEnabled()) {
  +LOG.warn(Invalid cookie header: \ 
  ++ header.getValue() 
  ++ \.  + e.getMessage());
   }
  -state.addCookie(cookie);
   }
  -
  -} catch (HttpException e) {
  -if (LOG.isWarnEnabled()) {
  -LOG.warn(Cookie rejected: \ 
  -+ setCookieHeader.getValue() 
  -+ \.  + e.getMessage());
  +if (cookies != null) {
  +for (int j = 0; j  cookies.length; j++) {
  +Cookie cookie = cookies[j];
  +try {
  +parser.validate(
  +  conn.getHost(),
  +  conn.getPort(),
  +  getPath(),
  +  conn.isSecure(),
  +  cookie);
  +state.addCookie(cookie);
  +if (LOG.isDebugEnabled()) {
  +LOG.debug(Cookie accepted: \ 
  ++ parser.formatCookie(cookie) + \);
  +}
  +} catch(MalformedCookieException e) {
  +if (LOG.isWarnEnabled()) {
  +LOG.warn(Cookie rejected: \ 
  ++ parser.formatCookie(cookie) + 
  +\.  + e.getMessage());
  +}
  +}
  +}
   }
   }
   }
  
  
  

-

cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-01-26 Thread jericho
jericho 2003/01/26 20:44:30

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  - Fix to be encoded double possbily...
  
  Reported by Joseph Artsimovich [EMAIL PROTECTED]
  
  Revision  ChangesPath
  1.100 +13 -5 
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.99
  retrieving revision 1.100
  diff -u -r1.99 -r1.100
  --- HttpMethodBase.java   25 Jan 2003 22:52:16 -  1.99
  +++ HttpMethodBase.java   27 Jan 2003 04:44:30 -  1.100
  @@ -277,7 +277,15 @@
   if (uri == null || uri.equals(  )) {
   uri = /;
   }
  -URI parsedURI = new URI( uri );
  +
  +URI parsedURI;
  +try {
  +// for an escaped form on communication functions
  +parsedURI = new URI(uri.toCharArray());
  +} catch (URIException urie) {
  +// it is supposed that an URI is sent not to be escaped
  +parsedURI = new URI(uri);
  +}
   
   // only set the host if specified by the URI
   if ( parsedURI.isAbsoluteURI() ) {
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-01-25 Thread olegk
olegk   2003/01/25 10:24:13

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Makes code in getResponseAsString() a bit more defensive
  
  Revision  ChangesPath
  1.98  +18 -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.97
  retrieving revision 1.98
  diff -u -r1.97 -r1.98
  --- HttpMethodBase.java   25 Jan 2003 03:28:29 -  1.97
  +++ HttpMethodBase.java   25 Jan 2003 18:24:13 -  1.98
  @@ -155,13 +155,13 @@
* @author a href=mailto:[EMAIL PROTECTED];dIon Gillard/a
* @author a href=mailto:[EMAIL PROTECTED];Jeff Dever/a
* @author a href=mailto:[EMAIL PROTECTED];Davanum Srinivas/a
  - * @author Ortwin Glück
  + * @author Ortwin Gl�ck
* @author Eric Johnson
* @author Michael Becke
* @author a href=mailto:[EMAIL PROTECTED];Oleg Kalnichevski/a
*/
   public abstract class HttpMethodBase implements HttpMethod {
  -//~ Static variables/initializers ··
  +//~ Static variables/initializers 
������������������������������������������
   
   /** Maximum number of redirects and authentications that will be followed */
   private static int maxForwards = 100;
  @@ -183,7 +183,7 @@
   USER_AGENT = new Header(User-Agent, agent);
   }
   
  -//~ Instance variables ·
  +//~ Instance variables 
�����������������������������������������������������
   
   /** My request headers, if any. */
   private Map requestHeaders = new HashMap();
  @@ -252,7 +252,7 @@
   
   private boolean doneWithConnection = false;
   
  -//~ Constructors ···
  +//~ Constructors 
�����������������������������������������������������������
   
   // --- Constructors
   
  @@ -306,7 +306,7 @@
   }
   }
   
  -//~ Methods 
  +//~ Methods 
����������������������������������������������������������������
   
   // --- Property Setters and Getters
   
  @@ -681,11 +681,16 @@
*/
   public String getResponseBodyAsString()
   {
  -if (!responseAvailable()) 
  -{
  -return null;
  + byte[] rawdata = null;
  +if (responseAvailable()) {
  +rawdata = getResponseBody();
   }
  -return HttpConstants.getContentString(getResponseBody(), 
getResponseCharSet());
  +if (rawdata != null) {
  + return HttpConstants.getContentString(rawdata, getResponseCharSet());
  +}
  + else {
  + return null;
  + }
   }
   
   
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-01-25 Thread olegk
olegk   2003/01/25 14:52:17

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Corrected garbled characters in comments
  
  Revision  ChangesPath
  1.99  +8 -11 
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.98
  retrieving revision 1.99
  diff -u -r1.98 -r1.99
  --- HttpMethodBase.java   25 Jan 2003 18:24:13 -  1.98
  +++ HttpMethodBase.java   25 Jan 2003 22:52:16 -  1.99
  @@ -155,13 +155,14 @@
* @author a href=mailto:[EMAIL PROTECTED];dIon Gillard/a
* @author a href=mailto:[EMAIL PROTECTED];Jeff Dever/a
* @author a href=mailto:[EMAIL PROTECTED];Davanum Srinivas/a
  - * @author Ortwin Gl�ck
  + * @author Ortwin Glück
* @author Eric Johnson
* @author Michael Becke
* @author a href=mailto:[EMAIL PROTECTED];Oleg Kalnichevski/a
*/
   public abstract class HttpMethodBase implements HttpMethod {
  -//~ Static variables/initializers 
������������������������������������������
  +
  +// -- Static variables/initializers 
   
   /** Maximum number of redirects and authentications that will be followed */
   private static int maxForwards = 100;
  @@ -183,7 +184,7 @@
   USER_AGENT = new Header(User-Agent, agent);
   }
   
  -//~ Instance variables 
�����������������������������������������������������
  +// - Instance variables 
   
   /** My request headers, if any. */
   private Map requestHeaders = new HashMap();
  @@ -252,8 +253,6 @@
   
   private boolean doneWithConnection = false;
   
  -//~ Constructors 
�����������������������������������������������������������
  -
   // --- Constructors
   
   /**
  @@ -305,8 +304,6 @@
   );
   }
   }
  -
  -//~ Methods 
����������������������������������������������������������������
   
   // --- Property Setters and Getters
   
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2003-01-24 Thread jericho
jericho 2003/01/24 19:28:30

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Fix a bug not to set an escaped query.
  (The setQueryString method requires an escaped form)
  
  Reported by Joseph Artsimovich [EMAIL PROTECTED]
  
  Revision  ChangesPath
  1.97  +14 -8 
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.96
  retrieving revision 1.97
  diff -u -r1.96 -r1.97
  --- HttpMethodBase.java   23 Jan 2003 22:47:47 -  1.96
  +++ HttpMethodBase.java   25 Jan 2003 03:28:29 -  1.97
  @@ -289,6 +289,7 @@
   parsedURI.getScheme()
   ); 
   }
  +// else { FIXME: just in case, is not abolsute uri, then?
   
   // set the path, defaulting to root
   setPath(
  @@ -296,7 +297,7 @@
   ? /
   : parsedURI.getPath()
   );
  -setQueryString( parsedURI.getQuery() );
  +setQueryString( parsedURI.getEscapedQuery() );
   
   } catch ( URIException e ) {
   throw new IllegalArgumentException( 
  @@ -324,7 +325,9 @@
   
   if ( hostConfiguration == null ) {
   // just use a relative URI, the host hasn't been set
  -return new URI( null, null, path, queryString, null );
  +URI tmpUri = new URI(null, null, path, null, null);
  +tmpUri.setEscapedQuery(queryString);
  +return tmpUri;
   } else {
   
   // we only want to include the port if it's not the default
  @@ -333,14 +336,17 @@
   port = -1;
   }
   
  -return new URI(
  +URI tmpUri = new URI(
   hostConfiguration.getProtocol().getScheme(),
   null,
   hostConfiguration.getHost(),
   port,
   path,
  -queryString
  +null // to set an escaped form
   );
  +tmpUri.setEscapedQuery(queryString);
  +return tmpUri;
  +
   }
   
   }
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2002-12-19 Thread oglueck
oglueck 2002/12/19 02:33:39

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Fixed exception when socket closes unexpectedly during response processing.
  Automatic retry instead.
  
  Reported by: Jack Adam
  
  Revision  ChangesPath
  1.92  +39 -36
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.91
  retrieving revision 1.92
  diff -u -r1.91 -r1.92
  --- HttpMethodBase.java   19 Dec 2002 10:23:35 -  1.91
  +++ HttpMethodBase.java   19 Dec 2002 10:33:38 -  1.92
  @@ -271,34 +271,34 @@
* @param uri either an absolute or relative URI
*/
   public HttpMethodBase(String uri) {
  -
  +
   try {
   // is this an absolute URI?
   URL url = new URL( uri );
  -
  +
   // set the path, defaulting to root
  -setPath( 
  +setPath(
   url.getPath() == null
   ? /
   : url.getPath()
   );
   setQueryString( url.getQuery() );
   hostConfiguration = new HostConfiguration();
  -hostConfiguration.setHost( 
  -url.getHost(), 
  -url.getPort(), 
  -url.getProtocol() 
  +hostConfiguration.setHost(
  +url.getHost(),
  +url.getPort(),
  +url.getProtocol()
   );
  -
  +
   } catch ( MalformedURLException e ) {
   // this is not a URL
   int pa = uri.indexOf(?);
  -
  +
   if ( !uri.startsWith(/) ) {
   // this path must be relative to root
   uri = / + uri;
   }
  -
  +
   if (pa  0) { //its just a path
   setPath(uri);
   } else { //its a path with a query
  @@ -306,7 +306,7 @@
   setQueryString(uri.substring(pa+1, uri.length()));
   }
   }
  -
  +
   }
   
   //~ Methods 
  @@ -325,19 +325,19 @@
* @see org.apache.commons.httpclient.HttpMethod#getURI()
*/
   public URI getURI() throws URIException {
  -
  +
   if ( hostConfiguration == null ) {
   // just use a relative URI, the host hasn't been set
   return new URI( null, null, path, queryString, null );
   } else {
  -
  +
   // we only want to include the port if it's not the default
   int port = hostConfiguration.getPort();
   if ( port == hostConfiguration.getProtocol().getDefaultPort() ) {
   port = -1;
   }
  -
  -return new URI( 
  +
  +return new URI(
   hostConfiguration.getProtocol().getScheme(),
   null,
   hostConfiguration.getHost(),
  @@ -346,7 +346,7 @@
   queryString
   );
   }
  -
  +
   }
   
   /**
  @@ -1285,7 +1285,7 @@
 state.getCookies());
   if ((cookies != null)  (cookies.length  0))
   {
  - setRequestHeader(matcher.formatCookieHeader(cookies));
  +setRequestHeader(matcher.formatCookieHeader(cookies));
   }
   }
   
  @@ -1334,7 +1334,7 @@
   if ( conn.getProtocol().getDefaultPort() != port ) {
   host += (: + port);
   }
  -
  +
   setRequestHeader(Host, host);
   }
   
  @@ -1567,18 +1567,18 @@
   
   CookieSpec parser = CookiePolicy.getDefaultSpec();
   Cookie[] cookies = parser.parse(
  -  conn.getHost(), 
  +  conn.getHost(),
 conn.getPort(),
  -  getPath(), 
  +  getPath(),
 conn.isSecure(),
 setCookieHeader);
   for (int i = 0; i  cookies.length; i++)
   {
   Cookie cookie = cookies[i];
   parser.validate(
  -  conn.getHost(), 
  +  conn.getHost(),
 conn.getPort(),
  -  getPath(), 
  +  getPath(),
 conn.isSecure(),
 cookie);
   if (log.isDebugEnabled()) {
  @@ -1586,7 +1586,7 @@
   }
   state.addCookie(cookie);
   }
  -  
  +
   } catch (HttpException e) {
   if (log.isWarnEnabled()) {
  

cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2002-12-11 Thread oglueck
oglueck 2002/12/11 05:21:43

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Fixed bug #15016
  
  Patch contributed by Michael Becke
  
  Revision  ChangesPath
  1.87  +9 -8  
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.86
  retrieving revision 1.87
  diff -u -r1.86 -r1.87
  --- HttpMethodBase.java   10 Dec 2002 04:05:03 -  1.86
  +++ HttpMethodBase.java   11 Dec 2002 13:21:43 -  1.87
  @@ -68,7 +68,6 @@
   import java.io.UnsupportedEncodingException;
   import java.net.MalformedURLException;
   import java.net.URL;
  -import java.util.Date;
   import java.util.HashMap;
   import java.util.HashSet;
   import java.util.Iterator;
  @@ -966,9 +965,11 @@
   return false;
   }
   
  -//update the current location with the redirect location
  -setPath(redirectUrl.getPath());
  -setQueryString(redirectUrl.getQuery());
  +//update the current location with the redirect location.
  +//avoiding use of URL.getPath() and URL.getQuery() to keep
  +//jdk1.2 comliance.
  +setPath( URIUtil.getPath( redirectUrl.toString() ) );
  +setQueryString( URIUtil.getQuery( redirectUrl.toString() ) );
   
   if (log.isDebugEnabled()) {
   log.debug(Redirecting from ' + currentUrl.toExternalForm()
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2002-12-09 Thread jsdever
jsdever 2002/12/09 20:05:03

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Fix bug introduced in a adding a cookie header.
  
  Revision  ChangesPath
  1.86  +5 -17 
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.85
  retrieving revision 1.86
  diff -u -r1.85 -r1.86
  --- HttpMethodBase.java   9 Dec 2002 09:16:16 -   1.85
  +++ HttpMethodBase.java   10 Dec 2002 04:05:03 -  1.86
  @@ -1224,19 +1224,7 @@
 state.getCookies());
   if ((cookies != null)  (cookies.length  0))
   {
  -if (this.strictMode)
  -{
  -// If in strict mode put all cookie in one header
  -setRequestHeader(matcher.formatCookieHeader(cookies));
  -}
  -else
  -{
  -// If not in strict mode put each cookie in a separate header
  -for(int i = 0; i  cookies.length; i++)
  -{
  -setRequestHeader(matcher.formatCookieHeader(cookies[i]));
  -}
  -}
  + setRequestHeader(matcher.formatCookieHeader(cookies));
   }
   }
   
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2002-10-28 Thread jsdever
jsdever 2002/10/28 23:51:40

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Handle any query string in the constructor seperately from the path.
  http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6624
  
  Committed by: Jeff Dever
  
  Revision  ChangesPath
  1.75  +12 -6 
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.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- HttpMethodBase.java   28 Oct 2002 14:20:30 -  1.74
  +++ HttpMethodBase.java   29 Oct 2002 07:51:40 -  1.75
   -254,10 +254,16 
   /**
* Path-specifying constructor.
* 
  - * param path my path
  + * param path my path which can include a query
*/
   public HttpMethodBase(String path) {
  -setPath(path);
  +int pa = path.indexOf(?);
  +if (pa  0) { //its just a path
  +setPath(path);
  +} else { //its a path with a query
  +setPath(path.substring(0, pa));
  +setQueryString(path.substring(pa+1, path.length()));
  +}
   }
   
   //~ Methods 
  
  
  

--
To unsubscribe, e-mail:   mailto:commons-dev-unsubscribe;jakarta.apache.org
For additional commands, e-mail: mailto:commons-dev-help;jakarta.apache.org




cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2002-10-22 Thread jericho
jericho 2002/10/22 18:39:39

  Modified:httpclient/src/java/org/apache/commons/httpclient/util
URIUtil.java
   httpclient/src/test/org/apache/commons/httpclient
TestWebappRedirect.java
   httpclient/src/java/org/apache/commons/httpclient/methods
PostMethod.java
   httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  - Add encodeInQuery in URIUtil class for HTTP URL (It's useful for query inside 
manipulation)
  - Apply the encodeInQuery method for inside of the query component
  
  Revision  ChangesPath
  1.6   +47 -16
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/util/URIUtil.java
  
  Index: URIUtil.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/util/URIUtil.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- URIUtil.java  21 Oct 2002 12:48:00 -  1.5
  +++ URIUtil.java  23 Oct 2002 01:39:39 -  1.6
   -83,6 +83,16 
   
   protected static final BitSet empty = new BitSet(1);
   
  +protected static final BitSet allowed_in_query = new BitSet(256);
  +// Static initializer for allowed_in_query
  +static {
  +allowed_in_query.or(URI.allowed_query);
  +allowed_in_query.clear('?');
  +allowed_in_query.clear('=');
  +allowed_in_query.clear('');
  +allowed_in_query.clear('#');
  +}
  +
   // -- URI utilities
   
   /**
   -195,6 +205,8 
   
   /**
* Get the all escaped and encoded string with the default protocl charset.
  + * It's the same function to use codeencode(String unescaped, Bitset
  + * empty, URI.getProtocolCharset())/code.
*
* param unescaped an unescaped string
* param charset the charset
   -210,6 +222,8 
   
   /**
* Get the all escaped and encoded string with a given charset.
  + * It's the same function to use codeencode(String unescaped, Bitset
  + * empty, String charset)/code.
*
* param unescaped an unescaped string
* param charset the charset
   -298,8 +312,8 
   
   
   /**
  - * Escape and encode a string regarded as the query component of an URI with
  - * the default protocol charset.
  + * Escape and encode a string regarded as inside the query component of an
  + * URI with the default protocol charset.
*
* param unescaped an unescaped string
* return the escaped string
   -307,14 +321,14 
* see URI#getProtocolCharset
* see #encode
*/
  -public static String encodeQuery(String unescaped) throws URIException {
  +public static String encodeInQuery(String unescaped) throws URIException {
   return encodeQuery(unescaped, URI.getProtocolCharset());
   }
   
   
   /**
  - * Escape and encode a string regarded as the query component of an URI with
  - * a given charset.
  + * Escape and encode a string regarded as inside the query component of an
  + * URI with a given charset.
*
* param unescaped an unescaped string
* param charset the charset
   -322,27 +336,44 
* exception URIException
* see #encode
*/
  -public static String encodeQuery(String unescaped, String charset)
  +public static String encodeInQuery(String unescaped, String charset)
   throws URIException {
   
  -return encode(unescaped, URI.allowed_query, charset);
  +return encode(unescaped, allowed_in_query, charset);
   }
   
   
   /**
  - * Escape and encode a given string and the default protocol charset.
  + * Escape and encode a string regarded as the query component of an URI with
  + * the default protocol charset.
*
  - * param unescaped a string
  + * param unescaped an unescaped string
* return the escaped string
* exception URIException
* see URI#getProtocolCharset
  - * see Coder#encode
  + * see #encode
*/
  -public static String encode(String unescaped)
  +public static String encodeQuery(String unescaped) throws URIException {
  +return encodeQuery(unescaped, URI.getProtocolCharset());
  +}
  +
  +
  +/**
  + * Escape and encode a string regarded as the query component of an URI with
  + * a given charset.
  + *
  + * param unescaped an unescaped string
  + * param charset the charset
  + * return the escaped string
  + * exception URIException
  + * see #encode
  + */
  +public static String encodeQuery(String unescaped, String charset)
   throws URIException {
   
  -return encode(unescaped, 

cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2002-10-21 Thread oglueck
oglueck 2002/10/21 05:28:15

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  fixed ? in parameter string
  
  Revision  ChangesPath
  1.68  +5 -5  
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.67
  retrieving revision 1.68
  diff -u -r1.67 -r1.68
  --- HttpMethodBase.java   21 Oct 2002 12:13:23 -  1.67
  +++ HttpMethodBase.java   21 Oct 2002 12:28:15 -  1.68
   -1325,7 +1325,7 
   }
   buf.append(path);
   if (query != null) {
  -if (query.indexOf(?)  0) {
  +if (query.indexOf(?) != 0) {
   buf.append(?);
   }
   String queryString = null;
  
  
  

--
To unsubscribe, e-mail:   mailto:commons-dev-unsubscribe;jakarta.apache.org
For additional commands, e-mail: mailto:commons-dev-help;jakarta.apache.org




Re: cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2002-10-21 Thread Sung-Gu
Hi oglueck,

I don't know who is the original writer though.
It looks like trying to attatch additional parameters.

I think it's required to make sure or document...
setQuery... method being called just one time or more?

Sung-Gu

- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, October 21, 2002 9:28 PM
Subject: cvs commit:
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java


 oglueck 2002/10/21 05:28:15

   Modified:httpclient/src/java/org/apache/commons/httpclient
 HttpMethodBase.java
   Log:
   fixed ? in parameter string

   Revision  ChangesPath
   1.68  +5 -5
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethod
Base.java

   Index: HttpMethodBase.java
   ===
   RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/
HttpMethodBase.java,v
   retrieving revision 1.67
   retrieving revision 1.68
   diff -u -r1.67 -r1.68
   --- HttpMethodBase.java 21 Oct 2002 12:13:23 - 1.67
   +++ HttpMethodBase.java 21 Oct 2002 12:28:15 - 1.68
   @@ -1325,7 +1325,7 @@
}
buf.append(path);
if (query != null) {
   -if (query.indexOf(?)  0) {
   +if (query.indexOf(?) != 0) {
buf.append(?);
}
String queryString = null;

--
To unsubscribe, e-mail:   mailto:commons-dev-unsubscribe;jakarta.apache.org
For additional commands, e-mail: mailto:commons-dev-help;jakarta.apache.org




Re: cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java URI.java

2002-10-21 Thread Sung-Gu
Hi Ortwin,

You're doing the opposite totally.  Why do you exlude them? ;)
And more, those characters're aleady included.  :-p
Just you need to get rid of the below code... Then ok.

Sung-Gu

P.S.: The URI class just deals with a string as an escaped sequence.

- Original Message -
From: [EMAIL PROTECTED]

   1.5   +6 -4
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/URI.java

   Index: URI.java
   ===
   RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/
URI.java,v
   retrieving revision 1.4
   retrieving revision 1.5
   diff -u -r1.4 -r1.5
   --- URI.java 16 Oct 2002 16:58:26 - 1.4
   +++ URI.java 21 Oct 2002 13:57:42 - 1.5
   @@ -1411,6 +1411,8 @@
static {
allowed_query.or(uric);
allowed_query.clear('%');
   +allowed_query.clear('=');
   +allowed_query.clear('');
}


--
To unsubscribe, e-mail:   mailto:commons-dev-unsubscribe;jakarta.apache.org
For additional commands, e-mail: mailto:commons-dev-help;jakarta.apache.org




cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2002-10-20 Thread jericho
jericho 2002/10/20 06:34:56

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  - Use httpclient.util.URIUtil methods instead of httpclient.URIUtil
  - Fix a bug not to encode of the query component, when the generateRequestLine 
method do
  - minor local variable naming change (from an abbreviation to a full string)
  
  Revision  ChangesPath
  1.66  +46 -19
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.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- HttpMethodBase.java   16 Oct 2002 16:58:26 -  1.65
  +++ HttpMethodBase.java   20 Oct 2002 13:34:55 -  1.66
   -77,6 +77,7 
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  +import org.apache.commons.httpclient.util.URIUtil;
   
   /**
* p
   -401,9 +402,23 
   } else {
   needAmp = true;
   }
  -buf.append(URIUtil.encode(params[i].getName())).append(=);
  +String queryName = null;
  +try {
  +queryName = URIUtil.encodeQuery(params[i].getName());
  +} catch (URIException urie) {
  +log.error(URI query name encoding error, urie);
  +queryName = params[i].getName();
  +}
  +buf.append(queryName).append(=);
   if (params[i].getValue() != null) {
  -buf.append(URIUtil.encode(params[i].getValue()));
  +String queryValue = null;
  +try {
  +queryValue = URIUtil.encodeQuery(params[i].getValue());
  +} catch (URIException urie) {
  +log.error(URI query value encoding error, urie);
  +queryValue = params[i].getValue();
  +}
  +buf.append(queryValue);
   }
   }
   }
   -855,11 +870,11 
   return statusCode;
   }
   
  -//change the path and query string to the redirect
  +// change the path and query string to the redirect
   String absolutePath = URIUtil.getPath(url.toString());
  -String qs = URIUtil.getQueryString(url.toString());
  +String query = URIUtil.getQuery(url.toString());
   setPath(URIUtil.decode(absolutePath));
  -setQueryString(qs);
  +setQueryString(URIUtil.decode(query));
   
   if (log.isDebugEnabled()) {
   log.debug(Changing path from \ + getPath()
   -867,7 +882,7 
 + \ in response to  + statusCode
 +  response.);
   log.debug(Changing query string from \
  -  + getQueryString() + \ to \ + qs
  +  + getQueryString() + \ to \ + query
 + \ in response to  + statusCode
 +  response.);
   }
   -1289,26 +1304,38 
* 
* param connection the connection the request will be sent to
* param name the method name generate a request for
  - * param reqPath the path for the request
  - * param qString the query string for the request
  + * param requestPath the path string for the request
  + * param query the query string for the request
* param protocol the protocol to use (e.g. HTTP/1.0)
* 
* return a line to send to the server that will fulfil the request
*/
   protected static String generateRequestLine(HttpConnection connection, 
  -String name, String reqPath, 
  -String qString, String protocol) {
  +String name, String requestPath, String query, String protocol) {
   log.trace(enter HttpMethodBase.generateRequestLine(HttpConnection, 
   + String, String, String, String));
   
   StringBuffer buf = new StringBuffer();
  -buf.append((null == reqPath)
  -   ? / : URIUtil.encode(reqPath, URIUtil.pathSafe()));
  -if (null != qString) {
  -if (qString.indexOf(?)  0) {
  +String path = null;
  +try {
  +path = (requestPath == null) ? / : URIUtil.encodePath(requestPath);
  +} catch (URIException urie) {
  +log.error(URI path encoding error);
  +path = 

cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java HttpMultiClient.java HttpStatus.java NameValuePair.java URI.java URIUtil.java

2002-10-16 Thread jsdever

jsdever 2002/10/16 09:58:26

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java HttpMultiClient.java
HttpStatus.java NameValuePair.java URI.java
URIUtil.java
  Log:
  Fix javadoc warnings.
  
  Contributed by: Justin Bedard
  
  Revision  ChangesPath
  1.65  +8 -7  
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.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- HttpMethodBase.java   15 Oct 2002 13:29:41 -  1.64
  +++ HttpMethodBase.java   16 Oct 2002 16:58:26 -  1.65
  @@ -287,7 +287,7 @@
   }
   
   /**
  - * Set whether or not I should use the HTTP/1.1 protocol. internal
  + * Set whether or not I should use the HTTP/1.1 protocol.
* 
* @param http11 true to use HTTP/1.1, false to use 1.0
*/
  @@ -320,7 +320,8 @@
   // -- Protected Utility Methods
   
   /**
  - * Return tttrue/tt if I should use the HTTP/1.1 protocol. internal
  + * Access to flag to determine if client should use 
  + * HTTP/1.1 protocol.
* 
* @return tttrue/tt if I should use the HTTP/1.1 protocol
*/
  @@ -1748,7 +1749,7 @@
   }
   
   /**
  - * Write the request body to the given {@link HttpConnection}
  + * Write the request body to the given {@link HttpConnection}.
* 
* p
* If an expectation is required, this method should ensure that it has
  
  
  
  1.17  +4 -4  
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMultiClient.java
  
  Index: HttpMultiClient.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMultiClient.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- HttpMultiClient.java  23 Sep 2002 07:01:52 -  1.16
  +++ HttpMultiClient.java  16 Oct 2002 16:58:26 -  1.17
  @@ -219,7 +219,7 @@
* Returns the value of the request timeout.
*
* @return the request timeout
  - * @see setRequestTimeout
  + * @see #setRequestTimeout(int)
*/
   public int getRequestTimeout() {
   return timeoutRequest;
  
  
  
  1.9   +7 -4  
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpStatus.java
  
  Index: HttpStatus.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpStatus.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- HttpStatus.java   5 Sep 2002 04:48:15 -   1.8
  +++ HttpStatus.java   16 Oct 2002 16:58:26 -  1.9
  @@ -208,6 +208,7 @@
   public static final int SC_EXPECTATION_FAILED = 417;
   
   /**
  + * Static constant for a 418 error.
* tt418 Unprocessable Entity/tt (WebDAV drafts?)
* or tt418 Reauthentication Required/tt (HTTP/1.1 drafts?)
*/
  @@ -215,6 +216,7 @@
   // public static final int SC_UNPROCESSABLE_ENTITY = 418;
   
   /**
  + * Static constant for a 419 error.
* tt419 Insufficient Space on Resource/tt
* (WebDAV - draft-ietf-webdav-protocol-05?)
* or tt419 Proxy Reauthentication Required/tt
  @@ -222,6 +224,7 @@
*/
   public static final int SC_INSUFFICIENT_SPACE_ON_RESOURCE = 419;
   /**
  + * Static constant for a 420 error.
* tt420 Method Failure/tt
* (WebDAV - draft-ietf-webdav-protocol-05?)
*/
  
  
  
  1.10  +6 -6  
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/NameValuePair.java
  
  Index: NameValuePair.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/NameValuePair.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- NameValuePair.java7 Sep 2002 16:45:48 -   1.9
  +++ NameValuePair.java16 Oct 2002 16:58:26 -  1.10
  @@ -191,8 +191,8 @@
   }
   
   /**
  - * Returns a hash code for this object such that
  - * if tta.{@link #equals equals}(b)/tt then
  + * hashCode. Returns a hash code for this object such 
  + * that if tta.{@link #equals equals}(b)/tt then
* tta.hashCode() == b.hashCode()/tt.
*/
   public int hashCode() {
  
  
  
  1.4   +66 -20

cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2002-10-15 Thread oglueck

oglueck 2002/10/15 06:29:42

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Fixed a hang on redirect
  
  Revision  ChangesPath
  1.64  +8 -4  
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.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- HttpMethodBase.java   13 Oct 2002 19:01:05 -  1.63
  +++ HttpMethodBase.java   15 Oct 2002 13:29:41 -  1.64
  @@ -889,6 +889,10 @@
   
   //close connection if required
   closeConnection(conn);
  +if (conn.isOpen()) {
  +//throw away body to position the stream after the response
  +getResponseBodyAsString();
  +}
   } //end of loop
   
   log.error(Narrowly avoided an infinite loop in execute);
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2002-10-13 Thread sullis

sullis  2002/10/13 12:01:05

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  HashMap variables are now declared as java.util.Map
  
  Revision  ChangesPath
  1.63  +6 -6  
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.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- HttpMethodBase.java   11 Oct 2002 08:34:31 -  1.62
  +++ HttpMethodBase.java   13 Oct 2002 19:01:05 -  1.63
  @@ -181,13 +181,13 @@
   //~ Instance variables ·
   
   /** My request headers, if any. */
  -private HashMap requestHeaders = new HashMap();
  +private Map requestHeaders = new HashMap();
   
   /** The Status-Line from the response. */
   private StatusLine statusLine = null;
   
   /** My response headers, if any. */
  -private HashMap responseHeaders = new HashMap();
  +private Map responseHeaders = new HashMap();
   
   /** My response footers, if any. */
   private Map responseFooters = null;
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2002-09-23 Thread jsdever

jsdever 2002/09/23 19:53:28

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Fix for redirect to default port -1 to port 80 failing.
  
  Refactor out the checking for valid redirect request into static method
  checkValidRedirect().  Added another static helper method that returns
  the default port number for a given protocol.  http-80, https-443
  
  Fix for bug: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12890
  
  Contributed by: Jeff Dever
  
  Revision  ChangesPath
  1.61  +75 -24
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.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- HttpMethodBase.java   12 Sep 2002 11:36:45 -  1.60
  +++ HttpMethodBase.java   24 Sep 2002 02:53:27 -  1.61
  @@ -817,15 +817,15 @@
 + ');
   }
   
  -URL url = null; //the new url
   
   //rfc2616 demands the location value be a complete URI
   //Location   = Location : absoluteURI
  +URL url = null; //the new url
   try {
   url = new URL(location);
   } catch (Exception ex) {
   if (isStrictMode()) {
  -log.error(Redirected location ' + 
locationHeader.getValue() +
  +log.error(Redirected location ' + location +
   ' is not acceptable in strict mode);
   return statusCode; //should we throw an exception?
   }
  @@ -846,24 +846,11 @@
   }
   
   //check for redirect to a different protocol, host or port
  -String error = null;
  -if (!conn.getProtocol().equalsIgnoreCase(
  -url.getProtocol())) {
  -error = Redirect from protocol  + conn.getProtocol()
  -+  to  + url.getProtocol()
  -+  is not supported;
  -}
  -if (!conn.getHost().equalsIgnoreCase(url.getHost())) {
  -error = Redirect from host  + conn.getHost() +  to 
  -+ url.getHost() +  is not supported;
  -}
  -if (conn.getPort() != url.getPort()) {
  -error = Redirect from port  + conn.getPort() +  to 
  -+ url.getPort() +  is not supported;
  -}
  -if (error != null) {
  -log.warn(error);
  -//throw new HttpException(error);
  +try{
  +checkValidRedirect(conn, url);
  +} catch (HttpException ex) {
  +//log the error and let the client handle the redirect
  +log.warn(ex.getMessage());
   return statusCode;
   }
   
  @@ -906,6 +893,70 @@
   
   log.error(Narrowly avoided an infinite loop in execute);
   throw new HttpException(Maximum redirects (+ maxForwards +) exceeded);
  +}
  +
  +
  +/** 
  + * Check for a valid redirect given the current conn and new url.
  + * Redirect to a different protocol, host or port are checked for validity.
  + *
  + * @param conn The existing HttpConnection
  + * @param url The new URL to redirect to
  + * @throws HttpException if the redirect is invalid
  + * @since 2.0
  + */
  +private static void checkValidRedirect(HttpConnection conn, URL url) 
  +throws HttpException {
  +log.trace(enter HttpMethodBase.checkValidRedirect(HttpConnection, URL));
  +
  +String oldProtocol = conn.getProtocol().toLowerCase();
  +String newProtocol = url.getProtocol().toLowerCase();
  +if (! oldProtocol.equals(newProtocol)) {
  +throw new HttpException(Redirect from protocol  + oldProtocol
  ++  to  + newProtocol +  is not supported);
  +}
  +
  +String oldHost = conn.getHost();
  +String newHost = url.getHost();
  +if (! oldHost.equalsIgnoreCase(newHost)) {
  +throw new HttpException(Redirect from host  + oldHost
  ++  to  + newHost +  is not supported);
  +}
  +
  +int oldPort = conn.getPort();
  +if (oldPort  0) {
  +oldPort = 

cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2002-04-12 Thread marcsaeg

marcsaeg02/04/12 14:13:59

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Removed the JDK 1.3 dependencies.  URL.getPath and URL.getQuery() have
  been replaced with URIUtil.getPath and URIUtil.getQueryString().
  
  Revision  ChangesPath
  1.27  +6 -9  
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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- HttpMethodBase.java   22 Feb 2002 19:20:35 -  1.26
  +++ HttpMethodBase.java   12 Apr 2002 21:13:59 -  1.27
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
 1.26 2002/02/22 19:20:35 marcsaeg Exp $
  - * $Revision: 1.26 $
  - * $Date: 2002/02/22 19:20:35 $
  + * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
 1.27 2002/04/12 21:13:59 marcsaeg Exp $
  + * $Revision: 1.27 $
  + * $Date: 2002/04/12 21:13:59 $
* 
*
* The Apache Software License, Version 1.1
  @@ -111,7 +111,7 @@
* @author Rodney Waldhoff
* @author Sean C. Sullivan
* @author a href=mailto:[EMAIL PROTECTED];dIon Gillard/a
  - * @version $Revision: 1.26 $ $Date: 2002/02/22 19:20:35 $
  + * @version $Revision: 1.27 $ $Date: 2002/04/12 21:13:59 $
*/
   public abstract class HttpMethodBase implements HttpMethod {
   
  @@ -619,11 +619,8 @@
   log.info(Server is attempting to redirect a different 
port, which is currently not supported. Returning  + statusCode + .);
   break;
   }
  -String absolutePath = url.getPath();
  -if (null == absolutePath) {
  -absolutePath = /;
  -}
  -String qs = url.getQuery();
  +String absolutePath = URIUtil.getPath(url.toString());
  +String qs = URIUtil.getQueryString(url.toString());
   
   // if we haven't already, let's try it again with the new 
path
   if (visited.contains(connection.getHost() + : + 
connection.getPort() + | + HttpMethodBase.generateRequestLine(connection, 
getName(),absolutePath,qs,(http11 ? HTTP/1.1 : HTTP/1.0 {
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java

2002-02-17 Thread dion

dion02/02/17 04:04:29

  Modified:httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java
  Log:
  Patches provided by Sean C Sullivan, fixed if statement formatting
  
  Revision  ChangesPath
  1.25  +122 -88   
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.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- HttpMethodBase.java   15 Jan 2002 20:53:47 -  1.24
  +++ HttpMethodBase.java   17 Feb 2002 12:04:29 -  1.25
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
 1.24 2002/01/15 20:53:47 rwaldhoff Exp $
  - * $Revision: 1.24 $
  - * $Date: 2002/01/15 20:53:47 $
  + * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
 1.25 2002/02/17 12:04:29 dion Exp $
  + * $Revision: 1.25 $
  + * $Date: 2002/02/17 12:04:29 $
* 
*
* The Apache Software License, Version 1.1
  @@ -109,7 +109,9 @@
*
* @author a href=mailto:[EMAIL PROTECTED];Remy Maucherat/a
* @author Rodney Waldhoff
  - * @version $Revision: 1.24 $ $Date: 2002/01/15 20:53:47 $
  + * @author Sean C. Sullivan
  + * @author a href=mailto:[EMAIL PROTECTED];dIon Gillard/a
  + * @version $Revision: 1.25 $ $Date: 2002/02/17 12:04:29 $
*/
   public abstract class HttpMethodBase implements HttpMethod {
   
  @@ -191,7 +193,7 @@
   // to the first, each separated by a comma.
   //   - HTTP/1.0 (4.3)
   Header header = (Header)(requestHeaders.get(headerName.toLowerCase()));
  -if(null == header) {
  +if (null == header) {
   header = new Header(headerName, headerValue);
   } else {
   header.setValue( (null == header.getValue() ?  : header.getValue()) +
  @@ -214,7 +216,7 @@
   // to the first, each separated by a comma.
   //   - HTTP/1.0 (4.3)
   Header orig = (Header)(requestHeaders.get(header.getName().toLowerCase()));
  -if(null == orig) {
  +if (null == orig) {
   orig = header;
   } else {
   orig.setValue( (null == orig.getValue() ?  : orig.getValue()) +
  @@ -278,15 +280,15 @@
   StringBuffer buf = new StringBuffer();
   boolean needAmp = false;
   for(int i=0;iparams.length;i++) {
  -if(needAmp) {
  +if (needAmp) {
   buf.append();
   } else {
   needAmp = true;
   }
  -if(null != params[i].getName()) {
  +if (null != params[i].getName()) {
   buf.append(URIUtil.encode(params[i].getName()));
   }
  -if(null != params[i].getValue()) {
  +if (null != params[i].getValue()) {
   buf.append(=);
   buf.append(URIUtil.encode(params[i].getValue()));
   }
  @@ -390,8 +392,8 @@
   /**
* Execute this method.
*
  - * @param state {@link HttpState} information to associate with this request
  - * @param connection the {@link HttpConnection} to write to/read from
  + * @param state {@link HttpState} information to associate with this request. 
Must be non-null.
  + * @param connection the {@link HttpConnection} to write to/read from. Must be 
non-null.
*
* @throws IOException if an I/O error occurs
* @throws HttpException  if an protocol exception occurs
  @@ -399,13 +401,23 @@
* @return the integer status code if one was obtained, or tt-1/tt
*/
   public int execute(HttpState state, HttpConnection connection) throws 
HttpException, IOException {
  -log.debug(HttpMethodBase.execute(HttpState,HttpConnection));
  +if (log.isDebugEnabled()) {
  + log.debug(HttpMethodBase.execute(HttpState,HttpConnection));
  +}
  +
  +if (null == state) {
  +throw new NullPointerException(HttpState parameter);
  +}
  +
  +if (null == connection) {
  +throw new NullPointerException(HttpConnection parameter);
  +}
   
  -if(hasBeenUsed()) {
  +if (hasBeenUsed()) {
   throw new HttpException(Already used, but not recycled.);
   }
   
  -if(!validate()) {
  +if (!validate()) {
   throw new HttpException(Not valid);
   }
   
  @@ -415,10 +427,14 @@
   for(;;) {
   visited.add(connection.getHost() + : + connection.getPort() + | + 
HttpMethodBase.generateRequestLine(connection,