hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r541979 - in /jakarta/httpcomponents/httpcore/trunk: module-main/src/main/java/org/apache/http/impl/ module-main/src/main/java/org/apache/http/params/ module-main/src/main/java/org/apache/http/protocol/ module-nio/src/examples/org/apache/ht...
Date Sun, 27 May 2007 12:50:51 GMT
Author: olegk
Date: Sun May 27 05:50:50 2007
New Revision: 541979

URL: http://svn.apache.org/viewvc?view=rev&rev=541979
Log:
params refactoring, step 4 - Http*Connections no longer link params

Modified:
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpConnectionParams.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpProtocolParams.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpService.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java?view=diff&rev=541979&r1=541978&r2=541979
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java
Sun May 27 05:50:50 2007
@@ -56,7 +56,6 @@
 import org.apache.http.message.BasicStatusLine;
 import org.apache.http.message.BufferedHeader;
 import org.apache.http.params.HttpParams;
-import org.apache.http.params.HttpProtocolParams;
 import org.apache.http.protocol.HTTP;
 import org.apache.http.util.CharArrayBuffer;
 import org.apache.http.util.HeaderUtils;
@@ -74,6 +73,7 @@
 public abstract class AbstractHttpClientConnection implements HttpClientConnection {
 
     private int maxHeaderCount = -1;
+    private int maxGarbageLines = -1;
 
     private final CharArrayBuffer buffer; 
     private final EntitySerializer entityserializer;
@@ -101,6 +101,10 @@
         this.maxHeaderCount = maxHeaderCount;
     }
     
+    protected void setMaxGarbageLines(int maxGarbageLines) {
+        this.maxGarbageLines = maxGarbageLines;
+    }
+    
     protected void setResponseFactory(final HttpResponseFactory responsefactory) {
         if (responsefactory == null) {
             throw new IllegalArgumentException("Factory may not be null");
@@ -195,7 +199,7 @@
         readResponseHeaders(response);
         return response;
     }
-
+    
     public void receiveResponseEntity(final HttpResponse response)
             throws HttpException, IOException {
         if (response == null) {
@@ -232,8 +236,6 @@
         // clear the buffer
         this.buffer.clear();
         //read out the HTTP status string
-        int maxGarbageLines = params.getIntParameter(
-                HttpProtocolParams.STATUS_LINE_GARBAGE_LIMIT, Integer.MAX_VALUE);
         int count = 0;
         do {
             int i = this.datareceiver.readLine(this.buffer);
@@ -244,7 +246,7 @@
             if (startsWithHTTP(this.buffer)) {
                 // Got one
                 break;
-            } else if (i == -1 || count >= maxGarbageLines) {
+            } else if (i == -1 || count >= this.maxGarbageLines) {
                 // Giving up
                 throw new ProtocolException("The server failed to respond with a " +
                         "valid HTTP response");
@@ -253,9 +255,7 @@
         } while(true);
         //create the status line from the status string
         StatusLine statusline = BasicStatusLine.parse(this.buffer, 0, this.buffer.length());
-        HttpResponse response = this.responsefactory.newHttpResponse(statusline, null);
-        response.getParams().setDefaults(params);
-        return response;
+        return this.responsefactory.newHttpResponse(statusline, null);
     }
 
     protected void readResponseHeaders(final HttpResponse response) 

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java?view=diff&rev=541979&r1=541978&r2=541979
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java
Sun May 27 05:50:50 2007
@@ -148,9 +148,7 @@
             throw new ConnectionClosedException("Client closed connection"); 
         }
         RequestLine requestline = BasicRequestLine.parse(this.buffer, 0, this.buffer.length());
-        HttpRequest request = this.requestfactory.newHttpRequest(requestline);
-        request.getParams().setDefaults(params);
-        return request;
+        return this.requestfactory.newHttpRequest(requestline);
     }
     
     protected void receiveRequestHeaders(final HttpRequest request) 

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java?view=diff&rev=541979&r1=541978&r2=541979
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
Sun May 27 05:50:50 2007
@@ -97,7 +97,10 @@
 
         setHttpDataReceiver(createHttpDataReceiver(params));
         setHttpDataTransmitter(createHttpDataTransmitter(params));
-        setMaxHeaderCount(params.getIntParameter(HttpConnectionParams.MAX_HEADER_COUNT, -1));
+        setMaxHeaderCount(params.getIntParameter(
+                HttpConnectionParams.MAX_HEADER_COUNT, -1));
+        setMaxGarbageLines(params.getIntParameter(
+                HttpConnectionParams.MAX_STATUS_LINE_GARBAGE, Integer.MAX_VALUE));
         setResponseFactory(new DefaultHttpResponseFactory());
         
         this.open = true;

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpConnectionParams.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpConnectionParams.java?view=diff&rev=541979&r1=541978&r2=541979
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpConnectionParams.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpConnectionParams.java
Sun May 27 05:50:50 2007
@@ -130,6 +130,26 @@
     public static final String MAX_HEADER_COUNT = "http.connection.max-header-count";
     
     /**
+     * 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";
+
+    /**
      */
     private HttpConnectionParams() {
         super();

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpProtocolParams.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpProtocolParams.java?view=diff&rev=541979&r1=541978&r2=541979
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpProtocolParams.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpProtocolParams.java
Sun May 27 05:50:50 2007
@@ -87,26 +87,6 @@
     public static final String ORIGIN_SERVER = "http.origin-server"; 
 
     /**
-     * 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 STATUS_LINE_GARBAGE_LIMIT = "http.protocol.status-line-garbage-limit";
-
-    /**
      * Defines whether responses with an invalid <tt>Transfer-Encoding</tt> header
should be 
      * rejected.
      * <p>

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpService.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpService.java?view=diff&rev=541979&r1=541978&r2=541979
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpService.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpService.java
Sun May 27 05:50:50 2007
@@ -131,6 +131,7 @@
         try {
 
             HttpRequest request = conn.receiveRequestHeader(this.params);
+            request.getParams().setDefaults(this.params);
             HttpVersion ver = request.getRequestLine().getHttpVersion();
             if (!ver.lessEquals(HttpVersion.HTTP_1_1)) {
                 // Downgrade protocol version if greater than HTTP/1.1 

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java?view=diff&rev=541979&r1=541978&r2=541979
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
Sun May 27 05:50:50 2007
@@ -360,7 +360,7 @@
                     response.removeHeaders(HTTP.CONN_DIRECTIVE);
                     response.removeHeaders("Keep-Alive");
                     
-                    response.getParams().setDefaults(this.params);
+                    response.setParams(this.params);
                     
                     // Pre-process HTTP request
                     context.setAttribute(HttpExecutionContext.HTTP_CONNECTION, conn);
@@ -500,7 +500,7 @@
             try {
                 HttpResponse response = this.responseFactory.newHttpResponse(
                         HttpVersion.HTTP_1_0, HttpStatus.SC_BAD_REQUEST, context);
-                response.getParams().setDefaults(this.params);
+                response.setParams(this.params);
                 response.addHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_CLOSE);
                 // Pre-process HTTP request
                 context.setAttribute(HttpExecutionContext.HTTP_CONNECTION, conn);
@@ -611,7 +611,7 @@
                 
                 try {
                     
-                    request.getParams().setDefaults(this.params);
+                    request.setParams(this.params);
                     
                     // Pre-process HTTP request
                     context.setAttribute(HttpExecutionContext.HTTP_CONNECTION, conn);



Mime
View raw message