hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1787706 - in /httpcomponents/httpclient/trunk/httpclient5-cache/src: main/java/org/apache/hc/client5/http/impl/cache/RequestProtocolCompliance.java test/java/org/apache/hc/client5/http/impl/cache/TestProtocolDeviations.java
Date Mon, 20 Mar 2017 10:11:41 GMT
Author: olegk
Date: Mon Mar 20 10:11:41 2017
New Revision: 1787706

URL: http://svn.apache.org/viewvc?rev=1787706&view=rev
Log:
Better handling of missing content-type header in OPTIONS with entity

Modified:
    httpcomponents/httpclient/trunk/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/RequestProtocolCompliance.java
    httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolDeviations.java

Modified: httpcomponents/httpclient/trunk/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/RequestProtocolCompliance.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/RequestProtocolCompliance.java?rev=1787706&r1=1787705&r2=1787706&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/RequestProtocolCompliance.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/RequestProtocolCompliance.java
Mon Mar 20 10:11:41 2017
@@ -32,8 +32,8 @@ import java.util.Iterator;
 import java.util.List;
 
 import org.apache.hc.client5.http.cache.HeaderConstants;
-import org.apache.hc.client5.http.protocol.ClientProtocolException;
 import org.apache.hc.client5.http.impl.sync.RoutedHttpRequest;
+import org.apache.hc.client5.http.protocol.ClientProtocolException;
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
 import org.apache.hc.core5.http.ClassicHttpResponse;
@@ -47,7 +47,7 @@ import org.apache.hc.core5.http.HttpRequ
 import org.apache.hc.core5.http.HttpStatus;
 import org.apache.hc.core5.http.HttpVersion;
 import org.apache.hc.core5.http.ProtocolVersion;
-import org.apache.hc.core5.http.io.entity.AbstractHttpEntity;
+import org.apache.hc.core5.http.io.entity.HttpEntityWrapper;
 import org.apache.hc.core5.http.message.BasicClassicHttpResponse;
 import org.apache.hc.core5.http.message.BasicHeader;
 import org.apache.hc.core5.http.message.MessageSupport;
@@ -191,7 +191,15 @@ class RequestProtocolCompliance {
     private void addContentTypeHeaderIfMissing(final RoutedHttpRequest request) {
         final HttpEntity entity = request.getEntity();
         if (entity != null && entity.getContentType() == null) {
-            ((AbstractHttpEntity) entity).setContentType(ContentType.APPLICATION_OCTET_STREAM.getMimeType());
+            final HttpEntityWrapper entityWrapper = new HttpEntityWrapper(entity) {
+
+                @Override
+                public String getContentType() {
+                    return ContentType.APPLICATION_OCTET_STREAM.getMimeType();
+                }
+
+            };
+            request.setEntity(entityWrapper);
         }
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolDeviations.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolDeviations.java?rev=1787706&r1=1787705&r2=1787706&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolDeviations.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolDeviations.java
Mon Mar 20 10:11:41 2017
@@ -32,10 +32,10 @@ import java.util.Random;
 import org.apache.hc.client5.http.HttpRoute;
 import org.apache.hc.client5.http.cache.HttpCacheContext;
 import org.apache.hc.client5.http.impl.sync.ClientExecChain;
+import org.apache.hc.client5.http.impl.sync.RoutedHttpRequest;
 import org.apache.hc.client5.http.protocol.ClientProtocolException;
 import org.apache.hc.client5.http.protocol.HttpClientContext;
 import org.apache.hc.client5.http.sync.methods.HttpExecutionAware;
-import org.apache.hc.client5.http.impl.sync.RoutedHttpRequest;
 import org.apache.hc.client5.http.utils.DateUtils;
 import org.apache.hc.core5.http.ClassicHttpRequest;
 import org.apache.hc.core5.http.ClassicHttpResponse;



Mime
View raw message