hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1684108 - in /httpcomponents/httpcore/trunk: httpcore-nio/src/main/java/org/apache/http/impl/nio/ httpcore-nio/src/main/java/org/apache/http/nio/protocol/ httpcore-nio/src/test/java/org/apache/http/impl/nio/ httpcore-nio/src/test/java/org/...
Date Mon, 08 Jun 2015 07:41:44 GMT
Author: olegk
Date: Mon Jun  8 07:41:44 2015
New Revision: 1684108

URL: http://svn.apache.org/r1684108
Log:
Removed support for 'identity' transfer encoding token

Added:
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/LengthRequiredException.java
      - copied, changed from r1684107, httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HeaderElements.java
Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/TestNHttpConnectionBase.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HeaderElements.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ContentLengthStrategy.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/DefaultContentLengthStrategy.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpService.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestHttpEntityWrapper.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestBHttpConnectionBase.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestDefaultContentLengthStrategy.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java?rev=1684108&r1=1684107&r2=1684108&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
Mon Jun  8 07:41:44 2015
@@ -36,7 +36,7 @@ import org.apache.http.HttpEntity;
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
-import org.apache.http.ProtocolException;
+import org.apache.http.LengthRequiredException;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.config.MessageConstraints;
 import org.apache.http.entity.ContentLengthStrategy;
@@ -86,7 +86,7 @@ public class DefaultNHttpClientConnectio
      * @param constraints Message constraints. If {@code null}
      *   {@link MessageConstraints#DEFAULT} will be used.
      * @param incomingContentStrategy incoming content length strategy. If {@code null}
-     *   {@link org.apache.http.impl.entity.LaxContentLengthStrategy#INSTANCE} will be used.
+     *   {@link DefaultContentLengthStrategy#INSTANCE} will be used.
      * @param outgoingContentStrategy outgoing content length strategy. If {@code null}
      *   {@link DefaultContentLengthStrategy#INSTANCE} will be used.
      *
@@ -272,8 +272,8 @@ public class DefaultNHttpClientConnectio
         if (request.getEntity() != null) {
             this.request = request;
             final long len = this.outgoingContentStrategy.determineLength(request);
-            if (len == ContentLengthStrategy.IDENTITY || len == ContentLengthStrategy.UNDEFINED)
{
-                throw new ProtocolException("Identity transfer encoding is not allowed for
request messages");
+            if (len == ContentLengthStrategy.UNDEFINED) {
+                throw new LengthRequiredException("Length required");
             }
             this.contentEncoder = createContentEncoder(
                     len,

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java?rev=1684108&r1=1684107&r2=1684108&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
Mon Jun  8 07:41:44 2015
@@ -36,7 +36,6 @@ import org.apache.http.HttpEntity;
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
-import org.apache.http.ProtocolException;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.config.MessageConstraints;
 import org.apache.http.entity.ContentLengthStrategy;
@@ -181,9 +180,6 @@ public class DefaultNHttpServerConnectio
                 } while (bytesRead > 0 && this.request == null);
                 if (this.request != null) {
                     final long len = this.incomingContentStrategy.determineLength(this.request);
-                    if (len == ContentLengthStrategy.IDENTITY) {
-                        throw new ProtocolException("Identity transfer encoding is not allowed
for request messages");
-                    }
                     if (len != ContentLengthStrategy.UNDEFINED) {
                         this.contentDecoder = createContentDecoder(
                                 len,

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java?rev=1684108&r1=1684107&r2=1684108&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
Mon Jun  8 07:41:44 2015
@@ -45,6 +45,7 @@ import org.apache.http.HttpResponseFacto
 import org.apache.http.HttpStatus;
 import org.apache.http.HttpVersion;
 import org.apache.http.MethodNotSupportedException;
+import org.apache.http.NotImplementedException;
 import org.apache.http.ProtocolException;
 import org.apache.http.UnsupportedHttpVersionException;
 import org.apache.http.annotation.Immutable;
@@ -564,6 +565,8 @@ public class HttpAsyncService implements
             code = HttpStatus.SC_NOT_IMPLEMENTED;
         } else if (ex instanceof UnsupportedHttpVersionException) {
             code = HttpStatus.SC_HTTP_VERSION_NOT_SUPPORTED;
+        } else if (ex instanceof NotImplementedException) {
+            code = HttpStatus.SC_NOT_IMPLEMENTED;
         } else if (ex instanceof ProtocolException) {
             code = HttpStatus.SC_BAD_REQUEST;
         } else {

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/TestNHttpConnectionBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/TestNHttpConnectionBase.java?rev=1684108&r1=1684107&r2=1684108&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/TestNHttpConnectionBase.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/TestNHttpConnectionBase.java
Mon Jun  8 07:41:44 2015
@@ -190,29 +190,18 @@ public class TestNHttpConnectionBase {
     }
 
     @Test
-    public void testCreateIdentityEntity() throws Exception {
-        final BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200,
"OK");
-        final HttpEntity entity = conn.createIncomingEntity(response, ContentLengthStrategy.IDENTITY);
-        Assert.assertNotNull(entity);
-        Assert.assertEquals(-1, entity.getContentLength());
-        Assert.assertFalse(entity.isChunked());
-        Assert.assertNull(entity.getContentType());
-        Assert.assertNull(entity.getContentEncoding());
-    }
-
-    @Test
     public void testCreateEntityWithContentLength() throws Exception {
         final BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200,
"OK");
         response.addHeader(HttpHeaders.CONTENT_LENGTH, "10");
         response.addHeader(HttpHeaders.CONTENT_TYPE, "stuff");
-        response.addHeader(HttpHeaders.CONTENT_ENCODING, "identity");
+        response.addHeader(HttpHeaders.CONTENT_ENCODING, "blah");
 
         final HttpEntity entity = conn.createIncomingEntity(response, 10);
         Assert.assertNotNull(entity);
         Assert.assertEquals(10, entity.getContentLength());
         Assert.assertFalse(entity.isChunked());
         Assert.assertEquals("stuff", entity.getContentType());
-        Assert.assertEquals("identity", entity.getContentEncoding());
+        Assert.assertEquals("blah", entity.getContentEncoding());
     }
 
     @Test
@@ -220,14 +209,14 @@ public class TestNHttpConnectionBase {
         final BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200,
"OK");
         response.addHeader(HttpHeaders.TRANSFER_ENCODING, "chunked");
         response.addHeader(HttpHeaders.CONTENT_TYPE, "stuff");
-        response.addHeader(HttpHeaders.CONTENT_ENCODING, "identity");
+        response.addHeader(HttpHeaders.CONTENT_ENCODING, "blah");
 
         final HttpEntity entity = conn.createIncomingEntity(response, ContentLengthStrategy.CHUNKED);
         Assert.assertNotNull(entity);
         Assert.assertEquals(-1, entity.getContentLength());
         Assert.assertTrue(entity.isChunked());
         Assert.assertEquals("stuff", entity.getContentType());
-        Assert.assertEquals("identity", entity.getContentEncoding());
+        Assert.assertEquals("blah", entity.getContentEncoding());
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java?rev=1684108&r1=1684107&r2=1684108&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java
Mon Jun  8 07:41:44 2015
@@ -369,7 +369,7 @@ public class TestHttpAsyncHandlers exten
 
         final HttpResponse response = future.get();
         Assert.assertNotNull(response);
-        Assert.assertEquals(HttpStatus.SC_BAD_REQUEST, response.getStatusLine().getStatusCode());
+        Assert.assertEquals(HttpStatus.SC_NOT_IMPLEMENTED, response.getStatusLine().getStatusCode());
     }
 
     @Test

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HeaderElements.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HeaderElements.java?rev=1684108&r1=1684107&r2=1684108&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HeaderElements.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HeaderElements.java
Mon Jun  8 07:41:44 2015
@@ -38,7 +38,6 @@ public final class HeaderElements {
     }
 
     public static final String CHUNKED_ENCODING = "chunked";
-    public static final String IDENTITY_ENCODING = "identity";
     public static final String CLOSE = "close";
     public static final String KEEP_ALIVE = "keep-alive";
     public static final String CONTINUE = "100-continue";

Copied: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/LengthRequiredException.java
(from r1684107, httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HeaderElements.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/LengthRequiredException.java?p2=httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/LengthRequiredException.java&p1=httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HeaderElements.java&r1=1684107&r2=1684108&rev=1684108&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/HeaderElements.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/LengthRequiredException.java
Mon Jun  8 07:41:44 2015
@@ -28,19 +28,28 @@
 package org.apache.http;
 
 /**
- * Constants for frequently used Header elements.
+ * Signals message rejection due to missing content length.
  *
- * @since 5.0
+ * @since 4.0
  */
-public final class HeaderElements {
+public class LengthRequiredException extends ProtocolException {
 
-    private HeaderElements() {
+    private static final long serialVersionUID = 1049109801075840707L;
+
+    /**
+     * Creates an exception without a detail message.
+     */
+    public LengthRequiredException() {
+        super();
     }
 
-    public static final String CHUNKED_ENCODING = "chunked";
-    public static final String IDENTITY_ENCODING = "identity";
-    public static final String CLOSE = "close";
-    public static final String KEEP_ALIVE = "keep-alive";
-    public static final String CONTINUE = "100-continue";
+    /**
+     * Creates an exception with the specified detail message.
+     *
+     * @param message The exception detail message
+     */
+    public LengthRequiredException(final String message) {
+        super(message);
+    }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ContentLengthStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ContentLengthStrategy.java?rev=1684108&r1=1684107&r2=1684108&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ContentLengthStrategy.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ContentLengthStrategy.java
Mon Jun  8 07:41:44 2015
@@ -39,15 +39,9 @@ import org.apache.http.HttpMessage;
 public interface ContentLengthStrategy {
 
     /**
-     * Identity transfer encoding. Message content is delineated
-     * by the end of connection.
-     */
-    int IDENTITY = -1;
-
-    /**
      * Message body chunk coded
      */
-    long CHUNKED = -2;
+    long CHUNKED = -1;
 
     /**
      * Message body not explicitly delineated. Legal for HTTP response messages
@@ -57,10 +51,9 @@ public interface ContentLengthStrategy {
 
     /**
      * Returns length of the given message in bytes. The returned value
-     * must be a non-negative number, {@link #IDENTITY} if the end of the
-     * message is delineated by the end of connection, {@link #CHUNKED}
-     * if the message is chunk coded, or {@link #UNDEFINED} if the message
-     * is not explicitly delineated.
+     * must be a non-negative number, {@link #CHUNKED} if the message is
+     * chunk coded, or {@link #UNDEFINED} if the message is not explicitly
+     * delineated.
      *
      * @param message HTTP message
      * @return content length, {@link #UNDEFINED}, or {@link #CHUNKED}

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java?rev=1684108&r1=1684107&r2=1684108&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
Mon Jun  8 07:41:44 2015
@@ -39,7 +39,7 @@ import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
-import org.apache.http.ProtocolException;
+import org.apache.http.LengthRequiredException;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.config.MessageConstraints;
 import org.apache.http.entity.ContentLengthStrategy;
@@ -149,8 +149,8 @@ public class DefaultBHttpClientConnectio
             return;
         }
         final long len = this.outgoingContentStrategy.determineLength(request);
-        if (len == ContentLengthStrategy.IDENTITY || len == ContentLengthStrategy.UNDEFINED)
{
-            throw new ProtocolException("Identity transfer encoding is not allowed for request
messages");
+        if (len == ContentLengthStrategy.UNDEFINED) {
+            throw new LengthRequiredException("Length required");
         }
         final OutputStream outstream = createContentOutputStream(len, this.outbuffer);
         entity.writeTo(outstream);

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java?rev=1684108&r1=1684107&r2=1684108&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
Mon Jun  8 07:41:44 2015
@@ -38,7 +38,6 @@ import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpServerConnection;
-import org.apache.http.ProtocolException;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.config.MessageConstraints;
 import org.apache.http.entity.ContentLengthStrategy;
@@ -148,8 +147,6 @@ public class DefaultBHttpServerConnectio
         final long len = this.incomingContentStrategy.determineLength(request);
         if (len == ContentLengthStrategy.UNDEFINED) {
             return;
-        } else if (len == ContentLengthStrategy.IDENTITY) {
-            throw new ProtocolException("Identity transfer encoding is not allowed for request
messages");
         }
         final HttpEntity entity = createIncomingEntity(request, this.inbuffer, len);
         request.setEntity(entity);

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/DefaultContentLengthStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/DefaultContentLengthStrategy.java?rev=1684108&r1=1684107&r2=1684108&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/DefaultContentLengthStrategy.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/entity/DefaultContentLengthStrategy.java
Mon Jun  8 07:41:44 2015
@@ -71,8 +71,6 @@ public class DefaultContentLengthStrateg
             final String s = transferEncodingHeader.getValue();
             if (HeaderElements.CHUNKED_ENCODING.equalsIgnoreCase(s)) {
                 return CHUNKED;
-            } else if (HeaderElements.IDENTITY_ENCODING.equalsIgnoreCase(s)) {
-                return IDENTITY;
             } else {
                 throw new NotImplementedException("Unsupported transfer encoding: " + s);
             }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpService.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpService.java?rev=1684108&r1=1684107&r2=1684108&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpService.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpService.java
Mon Jun  8 07:41:44 2015
@@ -41,6 +41,7 @@ import org.apache.http.HttpServerConnect
 import org.apache.http.HttpStatus;
 import org.apache.http.HttpVersion;
 import org.apache.http.MethodNotSupportedException;
+import org.apache.http.NotImplementedException;
 import org.apache.http.ProtocolException;
 import org.apache.http.UnsupportedHttpVersionException;
 import org.apache.http.annotation.Immutable;
@@ -247,6 +248,8 @@ public class HttpService {
             response.setStatusCode(HttpStatus.SC_NOT_IMPLEMENTED);
         } else if (ex instanceof UnsupportedHttpVersionException) {
             response.setStatusCode(HttpStatus.SC_HTTP_VERSION_NOT_SUPPORTED);
+        } else if (ex instanceof NotImplementedException) {
+            response.setStatusCode(HttpStatus.SC_NOT_IMPLEMENTED);
         } else if (ex instanceof ProtocolException) {
             response.setStatusCode(HttpStatus.SC_BAD_REQUEST);
         } else {

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestHttpEntityWrapper.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestHttpEntityWrapper.java?rev=1684108&r1=1684107&r2=1684108&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestHttpEntityWrapper.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestHttpEntityWrapper.java
Mon Jun  8 07:41:44 2015
@@ -44,7 +44,7 @@ public class TestHttpEntityWrapper {
     public void testBasics() throws Exception {
         final String s = "Message content";
         final StringEntity httpentity = new StringEntity(s, ContentType.TEXT_PLAIN);
-        httpentity.setContentEncoding("identity");
+        httpentity.setContentEncoding("blah");
         final HttpEntityWrapper wrapped = new HttpEntityWrapper(httpentity);
 
         Assert.assertEquals(httpentity.getContentLength(), wrapped.getContentLength());

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestBHttpConnectionBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestBHttpConnectionBase.java?rev=1684108&r1=1684107&r2=1684108&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestBHttpConnectionBase.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestBHttpConnectionBase.java
Mon Jun  8 07:41:44 2015
@@ -162,13 +162,13 @@ public class TestBHttpConnectionBase {
         final HttpResponse message = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
         message.addHeader("Content-Length", "10");
         message.addHeader("Content-Type", "stuff");
-        message.addHeader("Content-Encoding", "identity");
+        message.addHeader("Content-Encoding", "chunked");
         final HttpEntity entity = conn.createIncomingEntity(message, conn.inbuffer, 10);
         Assert.assertNotNull(entity);
         Assert.assertFalse(entity.isChunked());
         Assert.assertEquals(10, entity.getContentLength());
         Assert.assertEquals("stuff", entity.getContentType());
-        Assert.assertEquals("identity", entity.getContentEncoding());
+        Assert.assertEquals("chunked", entity.getContentEncoding());
         final InputStream instream = entity.getContent();
         Assert.assertNotNull(instream);
         Assert.assertTrue((instream instanceof ContentLengthInputStream));
@@ -188,19 +188,6 @@ public class TestBHttpConnectionBase {
     }
 
     @Test
-    public void testCreateEntityInputIdentity() throws Exception {
-        final HttpResponse message = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
-        final HttpEntity entity = conn.createIncomingEntity(message, conn.inbuffer,
-                ContentLengthStrategy.IDENTITY);
-        Assert.assertNotNull(entity);
-        Assert.assertFalse(entity.isChunked());
-        Assert.assertEquals(-1, entity.getContentLength());
-        final InputStream instream = entity.getContent();
-        Assert.assertNotNull(instream);
-        Assert.assertTrue((instream instanceof IdentityInputStream));
-    }
-
-    @Test
     public void testCreateEntityInputUndefined() throws Exception {
         final HttpResponse message = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
         final HttpEntity entity = conn.createIncomingEntity(message, conn.inbuffer,

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpClientConnection.java?rev=1684108&r1=1684107&r2=1684108&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpClientConnection.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpClientConnection.java
Mon Jun  8 07:41:44 2015
@@ -36,7 +36,8 @@ import org.apache.http.HttpEntity;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpVersion;
-import org.apache.http.ProtocolException;
+import org.apache.http.LengthRequiredException;
+import org.apache.http.NotImplementedException;
 import org.apache.http.config.MessageConstraints;
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.StringEntity;
@@ -45,7 +46,6 @@ import org.apache.http.impl.io.ChunkedIn
 import org.apache.http.impl.io.ContentLengthInputStream;
 import org.apache.http.impl.io.DefaultHttpRequestWriterFactory;
 import org.apache.http.impl.io.DefaultHttpResponseParserFactory;
-import org.apache.http.impl.io.IdentityInputStream;
 import org.apache.http.message.BasicHttpRequest;
 import org.junit.Assert;
 import org.junit.Before;
@@ -157,7 +157,7 @@ public class TestDefaultBHttpClientConne
         Assert.assertTrue(content instanceof ChunkedInputStream);
     }
 
-    @Test
+    @Test(expected = NotImplementedException.class)
     public void testReadResponseEntityIdentity() throws Exception {
         final String s = "HTTP/1.1 200 OK\r\nServer: test\r\nTransfer-Encoding: identity\r\n\r\n123";
         final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes(Consts.ASCII));
@@ -176,15 +176,6 @@ public class TestDefaultBHttpClientConne
         Assert.assertEquals(1, conn.getMetrics().getResponseCount());
 
         conn.receiveResponseEntity(response);
-
-        final HttpEntity entity = response.getEntity();
-        Assert.assertNotNull(entity);
-        Assert.assertEquals(-1, entity.getContentLength());
-        Assert.assertEquals(false, entity.isChunked());
-        Assert.assertEquals(1, conn.getMetrics().getResponseCount());
-        final InputStream content = entity.getContent();
-        Assert.assertNotNull(content);
-        Assert.assertTrue(content instanceof IdentityInputStream);
     }
 
     @Test
@@ -278,8 +269,8 @@ public class TestDefaultBHttpClientConne
                 "chunked\r\n\r\n3\r\n123\r\n0\r\n\r\n", s);
     }
 
-    @Test(expected = ProtocolException.class)
-    public void testWriteRequestEntityIdentity() throws Exception {
+    @Test(expected = LengthRequiredException.class)
+    public void testWriteRequestEntityNoContentLength() throws Exception {
         final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
         Mockito.when(socket.getOutputStream()).thenReturn(outstream);
 
@@ -289,7 +280,6 @@ public class TestDefaultBHttpClientConne
 
         final HttpRequest request = new BasicHttpRequest("POST", "/stuff", HttpVersion.HTTP_1_1);
         request.addHeader("User-Agent", "test");
-        request.addHeader("Transfer-Encoding", "identity");
         request.setEntity(new StringEntity("123", ContentType.TEXT_PLAIN));
 
         conn.sendRequestHeader(request);

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpServerConnection.java?rev=1684108&r1=1684107&r2=1684108&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpServerConnection.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpServerConnection.java
Mon Jun  8 07:41:44 2015
@@ -36,6 +36,7 @@ import org.apache.http.HttpEntity;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpVersion;
+import org.apache.http.NotImplementedException;
 import org.apache.http.ProtocolException;
 import org.apache.http.config.MessageConstraints;
 import org.apache.http.entity.ContentType;
@@ -297,7 +298,7 @@ public class TestDefaultBHttpServerConne
                 "chunked\r\n\r\n3\r\n123\r\n0\r\n\r\n", s);
     }
 
-    @Test
+    @Test(expected = NotImplementedException.class)
     public void testWriteResponseEntityIdentity() throws Exception {
         final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
         Mockito.when(socket.getOutputStream()).thenReturn(outstream);
@@ -314,10 +315,6 @@ public class TestDefaultBHttpServerConne
         conn.sendResponseHeader(response);
         conn.sendResponseEntity(response);
         conn.flush();
-
-        Assert.assertEquals(1, conn.getMetrics().getResponseCount());
-        final String s = new String(outstream.toByteArray(), "ASCII");
-        Assert.assertEquals("HTTP/1.1 200 OK\r\nServer: test\r\nTransfer-Encoding: identity\r\n\r\n123",
s);
     }
 
     @Test

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestDefaultContentLengthStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestDefaultContentLengthStrategy.java?rev=1684108&r1=1684107&r2=1684108&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestDefaultContentLengthStrategy.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestDefaultContentLengthStrategy.java
Mon Jun  8 07:41:44 2015
@@ -29,6 +29,7 @@ package org.apache.http.impl.entity;
 
 import org.apache.http.HttpMessage;
 import org.apache.http.HttpVersion;
+import org.apache.http.NotImplementedException;
 import org.apache.http.ProtocolException;
 import org.apache.http.ProtocolVersion;
 import org.apache.http.entity.ContentLengthStrategy;
@@ -56,13 +57,12 @@ public class TestDefaultContentLengthStr
         Assert.assertEquals(ContentLengthStrategy.CHUNKED, lenStrategy.determineLength(message));
     }
 
-    @Test
+    @Test(expected = NotImplementedException.class)
     public void testEntityWithIdentityTransferEncoding() throws Exception {
         final ContentLengthStrategy lenStrategy = new DefaultContentLengthStrategy();
         final HttpMessage message = new TestHttpMessage();
         message.addHeader("Transfer-Encoding", "Identity");
-
-        Assert.assertEquals(ContentLengthStrategy.IDENTITY, lenStrategy.determineLength(message));
+        lenStrategy.determineLength(message);
     }
 
     @Test(expected=ProtocolException.class)

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java?rev=1684108&r1=1684107&r2=1684108&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
Mon Jun  8 07:41:44 2015
@@ -49,9 +49,9 @@ import org.apache.http.HttpRequestInterc
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
 import org.apache.http.HttpVersion;
+import org.apache.http.entity.AbstractHttpEntity;
 import org.apache.http.entity.ByteArrayEntity;
 import org.apache.http.entity.ContentType;
-import org.apache.http.entity.AbstractHttpEntity;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.DefaultBHttpClientConnection;
 import org.apache.http.message.BasicHttpRequest;
@@ -888,7 +888,7 @@ public class TestSyncHttp {
                     new RequestExpectContinue()));
 
             final HttpResponse response = this.client.execute(post, host, conn);
-            Assert.assertEquals(HttpStatus.SC_BAD_REQUEST, response.getStatusLine().getStatusCode());
+            Assert.assertEquals(HttpStatus.SC_NOT_IMPLEMENTED, response.getStatusLine().getStatusCode());
         } finally {
             conn.close();
             this.server.shutdown();



Mime
View raw message