hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r562715 - in /jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http: conn/params/HttpConnectionManagerParams.java impl/conn/DefaultClientConnection.java impl/conn/DefaultResponseParser.java
Date Sat, 04 Aug 2007 13:14:40 GMT
Author: olegk
Date: Sat Aug  4 06:14:39 2007
New Revision: 562715

URL: http://svn.apache.org/viewvc?view=rev&rev=562715
Log:
HTTPCORE-106: Moved garbage tolerant HTTP response parser to HttpClient

Added:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/DefaultResponseParser.java
      - copied, changed from r562711, jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/io/HttpResponseParser.java
Modified:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/HttpConnectionManagerParams.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/HttpConnectionManagerParams.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/HttpConnectionManagerParams.java?view=diff&rev=562715&r1=562714&r2=562715
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/HttpConnectionManagerParams.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/HttpConnectionManagerParams.java
Sat Aug  4 06:14:39 2007
@@ -82,6 +82,25 @@
      */
     public static final String MAX_TOTAL_CONNECTIONS = "http.connection-manager.max-total";
 
+    /**
+     * Defines the maximum number of ignorable lines before we expect
+     * a HTTP response's status code.
+     * <p>
+     * With HTTP/1.1 persistent connections, the problem arises that
+     * broken scripts could return a wrong Content-Length
+     * (there are more bytes sent than specified).<br />
+     * Unfortunately, in some cases, this is not possible after the bad response,
+     * but only before the next one. <br />
+     * So, HttpClient must be able to skip those surplus lines this way.
+     * </p>
+     * <p>
+     * Set this to 0 to disallow any garbage/empty lines before the status line.<br />
+     * To specify no limit, use {@link java.lang.Integer#MAX_VALUE} (default in lenient mode).
+     * </p>
+     *  
+     * This parameter expects a value of type {@link Integer}.
+     */
+    public static final String MAX_STATUS_LINE_GARBAGE = "http.connection.max-status-line-garbage";
 
     /**
      * Sets the default maximum number of connections allowed for routes.

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java?view=diff&rev=562715&r1=562714&r2=562715
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
Sat Aug  4 06:14:39 2007
@@ -42,8 +42,10 @@
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
+import org.apache.http.HttpResponseFactory;
 import org.apache.http.params.HttpParams;
 import org.apache.http.impl.SocketHttpClientConnection;
+import org.apache.http.io.HttpMessageParser;
 import org.apache.http.io.SessionInputBuffer;
 import org.apache.http.io.SessionOutputBuffer;
 
@@ -166,6 +168,14 @@
     }
 
     
+    protected HttpMessageParser createResponseParser(
+            final SessionInputBuffer buffer,
+            final HttpResponseFactory responseFactory, 
+            final HttpParams params) {
+        return new DefaultResponseParser(buffer, responseFactory, params);
+    }
+
+
     // non-javadoc, see interface OperatedClientConnection
     public void open(Socket sock, HttpHost target,
                      boolean secure, HttpParams params)

Copied: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/DefaultResponseParser.java
(from r562711, jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/io/HttpResponseParser.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/DefaultResponseParser.java?view=diff&rev=562715&p1=jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/io/HttpResponseParser.java&r1=562711&p2=jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/DefaultResponseParser.java&r2=562715
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/io/HttpResponseParser.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/DefaultResponseParser.java
Sat Aug  4 06:14:39 2007
@@ -29,7 +29,7 @@
  *
  */
 
-package org.apache.http.impl.io;
+package org.apache.http.impl.conn;
 
 import java.io.IOException;
 
@@ -39,20 +39,21 @@
 import org.apache.http.NoHttpResponseException;
 import org.apache.http.ProtocolException;
 import org.apache.http.StatusLine;
+import org.apache.http.conn.params.HttpConnectionManagerParams;
+import org.apache.http.impl.io.AbstractMessageParser;
 import org.apache.http.io.SessionInputBuffer;
 import org.apache.http.message.BasicStatusLine;
-import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.HTTP;
 import org.apache.http.util.CharArrayBuffer;
 
-public class HttpResponseParser extends AbstractMessageParser {
+public class DefaultResponseParser extends AbstractMessageParser {
     
     private final HttpResponseFactory responseFactory;
     private final CharArrayBuffer lineBuf;
     private final int maxGarbageLines;
     
-    public HttpResponseParser(
+    public DefaultResponseParser(
             final SessionInputBuffer buffer,
             final HttpResponseFactory responseFactory,
             final HttpParams params) {
@@ -63,7 +64,7 @@
         this.responseFactory = responseFactory;
         this.lineBuf = new CharArrayBuffer(128);
         this.maxGarbageLines = params.getIntParameter(
-                HttpConnectionParams.MAX_STATUS_LINE_GARBAGE, Integer.MAX_VALUE);
+                HttpConnectionManagerParams.MAX_STATUS_LINE_GARBAGE, Integer.MAX_VALUE);
     }
 
     /**



Mime
View raw message