hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1334646 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java/org/apache/http/conn/params/ main/java/org/apache/http/impl/conn/ test/java/org/apache/http/impl/conn/
Date Sun, 06 May 2012 14:41:38 GMT
Author: olegk
Date: Sun May  6 14:41:38 2012
New Revision: 1334646

URL: http://svn.apache.org/viewvc?rev=1334646&view=rev
Log:
Deprecated DefaultResponseParser in favor of DefaultHttpResponseParser

Added:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java
      - copied, changed from r1334634, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultResponseParser.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultHttpResponseParser.java
  (contents, props changed)
      - copied, changed from r1334634, httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultResponseParser.java
Removed:
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultResponseParser.java
Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionPNames.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultResponseParser.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionPNames.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionPNames.java?rev=1334646&r1=1334645&r2=1334646&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionPNames.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionPNames.java
Sun May  6 14:41:38 2012
@@ -26,7 +26,7 @@
 
 package org.apache.http.conn.params;
 
-import org.apache.http.impl.conn.DefaultResponseParser;
+import org.apache.http.impl.conn.DefaultHttpResponseParser;
 
 /**
  * Parameter names for HTTP client connections.
@@ -53,7 +53,7 @@ public interface ConnConnectionPNames {
      * Use {@link java.lang.Integer#MAX_VALUE} for unlimited number.
      * </p>
      *
-     * @deprecated Use custom {@link DefaultResponseParser} implementation
+     * @deprecated Use custom {@link DefaultHttpResponseParser} implementation
      */
     public static final String MAX_STATUS_LINE_GARBAGE = "http.connection.max-status-line-garbage";
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java?rev=1334646&r1=1334645&r2=1334646&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
Sun May  6 14:41:38 2012
@@ -221,7 +221,7 @@ public class DefaultClientConnection ext
             final HttpResponseFactory responseFactory,
             final HttpParams params) {
         // override in derived class to specify a line parser
-        return new DefaultResponseParser
+        return new DefaultHttpResponseParser
             (buffer, null, responseFactory, params);
     }
 

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java
(from r1334634, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultResponseParser.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultResponseParser.java&r1=1334634&r2=1334646&rev=1334646&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultResponseParser.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java
Sun May  6 14:41:38 2012
@@ -54,21 +54,19 @@ import org.apache.http.util.CharArrayBuf
  * <ul>
  *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_HEADER_COUNT}</li>
  *  <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}</li>
- *  <li>{@link org.apache.http.conn.params.ConnConnectionPNames#MAX_STATUS_LINE_GARBAGE}</li>
  * </ul>
  *
- * @since 4.0
+ * @since 4.2
  */
 @ThreadSafe // no public methods
-public class DefaultResponseParser extends AbstractMessageParser<HttpResponse> {
+public class DefaultHttpResponseParser extends AbstractMessageParser<HttpResponse>
{
 
     private final Log log = LogFactory.getLog(getClass());
 
     private final HttpResponseFactory responseFactory;
     private final CharArrayBuffer lineBuf;
-    private final int maxGarbageLines;
 
-    public DefaultResponseParser(
+    public DefaultHttpResponseParser(
             final SessionInputBuffer buffer,
             final LineParser parser,
             final HttpResponseFactory responseFactory,
@@ -80,17 +78,6 @@ public class DefaultResponseParser exten
         }
         this.responseFactory = responseFactory;
         this.lineBuf = new CharArrayBuffer(128);
-        this.maxGarbageLines = getMaxGarbageLines(params);
-    }
-
-    /**
-     * @since 4.2
-     */
-    @SuppressWarnings("deprecation")
-    protected int getMaxGarbageLines(final HttpParams params) {
-        return params.getIntParameter(
-                org.apache.http.conn.params.ConnConnectionPNames.MAX_STATUS_LINE_GARBAGE,
-                Integer.MAX_VALUE);
     }
 
     @Override
@@ -111,7 +98,7 @@ public class DefaultResponseParser exten
             if (lineParser.hasProtocolVersion(this.lineBuf, cursor)) {
                 // Got one
                 break;
-            } else if (i == -1 || count >= this.maxGarbageLines) {
+            } else if (i == -1 || reject(this.lineBuf, count)) {
                 // Giving up
                 throw new ProtocolException("The server failed to respond with a " +
                         "valid HTTP response");
@@ -126,4 +113,8 @@ public class DefaultResponseParser exten
         return this.responseFactory.newHttpResponse(statusline, null);
     }
 
+    protected boolean reject(CharArrayBuffer line, int count) {
+        return false;
+    }
+    
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultResponseParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultResponseParser.java?rev=1334646&r1=1334645&r2=1334646&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultResponseParser.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultResponseParser.java
Sun May  6 14:41:38 2012
@@ -34,7 +34,7 @@ import org.apache.http.annotation.Thread
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.http.HttpException;
-import org.apache.http.HttpResponse;
+import org.apache.http.HttpMessage;
 import org.apache.http.HttpResponseFactory;
 import org.apache.http.NoHttpResponseException;
 import org.apache.http.ProtocolException;
@@ -58,9 +58,11 @@ import org.apache.http.util.CharArrayBuf
  * </ul>
  *
  * @since 4.0
+ * 
+ * @deprecated (4.2) use {@link DefaultHttpResponseParser}
  */
 @ThreadSafe // no public methods
-public class DefaultResponseParser extends AbstractMessageParser<HttpResponse> {
+public class DefaultResponseParser extends AbstractMessageParser<HttpMessage> {
 
     private final Log log = LogFactory.getLog(getClass());
 
@@ -83,10 +85,6 @@ public class DefaultResponseParser exten
         this.maxGarbageLines = getMaxGarbageLines(params);
     }
 
-    /**
-     * @since 4.2
-     */
-    @SuppressWarnings("deprecation")
     protected int getMaxGarbageLines(final HttpParams params) {
         return params.getIntParameter(
                 org.apache.http.conn.params.ConnConnectionPNames.MAX_STATUS_LINE_GARBAGE,
@@ -94,7 +92,7 @@ public class DefaultResponseParser exten
     }
 
     @Override
-    protected HttpResponse parseHead(
+    protected HttpMessage parseHead(
             final SessionInputBuffer sessionBuffer) throws IOException, HttpException {
         //read out the HTTP status string
         int count = 0;

Copied: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultHttpResponseParser.java
(from r1334634, httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultResponseParser.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultHttpResponseParser.java?p2=httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultHttpResponseParser.java&p1=httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultResponseParser.java&r1=1334634&r2=1334646&rev=1334646&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultResponseParser.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultHttpResponseParser.java
Sun May  6 14:41:38 2012
@@ -39,13 +39,14 @@ import org.apache.http.message.BasicLine
 import org.apache.http.mockup.SessionInputBufferMockup;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
+import org.apache.http.util.CharArrayBuffer;
 import org.junit.Assert;
 import org.junit.Test;
 
 /**
  * Tests for <code>DefaultResponseParser</code>.
  */
-public class TestDefaultResponseParser {
+public class TestDefaultHttpResponseParser {
 
     @Test
     public void testResponseParsingWithSomeGarbage() throws Exception {
@@ -60,7 +61,7 @@ public class TestDefaultResponseParser {
 
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
-        HttpMessageParser<HttpResponse> parser = new DefaultResponseParser(
+        HttpMessageParser<HttpResponse> parser = new DefaultHttpResponseParser(
                 inbuffer,
                 BasicLineParser.DEFAULT,
                 new DefaultHttpResponseFactory(),
@@ -91,15 +92,15 @@ public class TestDefaultResponseParser {
 
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
-        HttpMessageParser<HttpResponse> parser = new DefaultResponseParser(
+        HttpMessageParser<HttpResponse> parser = new DefaultHttpResponseParser(
                 inbuffer,
                 BasicLineParser.DEFAULT,
                 new DefaultHttpResponseFactory(),
                 params) {
 
                     @Override
-                    protected int getMaxGarbageLines(HttpParams params) {
-                        return 2;
+                    protected boolean reject(final CharArrayBuffer line, int count) {
+                        return count >= 2;
                     }
 
         };
@@ -110,7 +111,7 @@ public class TestDefaultResponseParser {
     public void testResponseParsingNoResponse() throws Exception {
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuffer = new SessionInputBufferMockup("", "US-ASCII", params);
-        HttpMessageParser<HttpResponse> parser = new DefaultResponseParser(
+        HttpMessageParser<HttpResponse> parser = new DefaultHttpResponseParser(
                 inbuffer,
                 BasicLineParser.DEFAULT,
                 new DefaultHttpResponseFactory(),
@@ -127,7 +128,7 @@ public class TestDefaultResponseParser {
             "a lot more garbage\r\n";
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
-        HttpMessageParser<HttpResponse> parser = new DefaultResponseParser(
+        HttpMessageParser<HttpResponse> parser = new DefaultHttpResponseParser(
                 inbuffer,
                 BasicLineParser.DEFAULT,
                 new DefaultHttpResponseFactory(),

Propchange: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultHttpResponseParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultHttpResponseParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultHttpResponseParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message