hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r413272 - in /jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol: RequestContent.java ResponseContent.java
Date Sat, 10 Jun 2006 08:53:17 GMT
Author: olegk
Date: Sat Jun 10 01:53:16 2006
New Revision: 413272

URL: http://svn.apache.org/viewvc?rev=413272&view=rev
Log:
Do not overwrite custom ContentType and ContentEncoding headers

Modified:
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/RequestContent.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/ResponseContent.java

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/RequestContent.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/RequestContent.java?rev=413272&r1=413271&r2=413272&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/RequestContent.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/RequestContent.java
Sat Jun 10 01:53:16 2006
@@ -69,7 +69,7 @@
             HttpVersion ver = request.getRequestLine().getHttpVersion();
             HttpEntity entity = ((HttpEntityEnclosingRequest)request).getEntity();
             if (entity == null) {
-                request.setHeader(new GeneratedHeader(HTTP.CONTENT_LEN, "0"));
+                request.addHeader(new GeneratedHeader(HTTP.CONTENT_LEN, "0"));
                 return;
             }
             // Must specify a transfer encoding or a content length 
@@ -85,12 +85,14 @@
                         Long.toString(entity.getContentLength())));
             }
             // Specify a content type if known
-            if (entity.getContentType() != null) {
-                request.setHeader(entity.getContentType()); 
+            if (entity.getContentType() != null && !request.containsHeader(
+                    HTTP.CONTENT_TYPE )) {
+                request.addHeader(entity.getContentType()); 
             }
             // Specify a content encoding if known
-            if (entity.getContentEncoding() != null) {
-                request.setHeader(entity.getContentEncoding()); 
+            if (entity.getContentEncoding() != null && !request.containsHeader(
+                    HTTP.CONTENT_ENCODING)) {
+                request.addHeader(entity.getContentEncoding()); 
             }
         }
     }

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/ResponseContent.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/ResponseContent.java?rev=413272&r1=413271&r2=413272&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/ResponseContent.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/ResponseContent.java
Sat Jun 10 01:53:16 2006
@@ -78,12 +78,14 @@
                         Long.toString(entity.getContentLength())));
             }
             // Specify a content type if known
-            if (entity.getContentType() != null) {
-                response.setHeader(entity.getContentType()); 
+            if (entity.getContentType() != null && !response.containsHeader(
+                    HTTP.CONTENT_TYPE )) {
+                response.addHeader(entity.getContentType()); 
             }
             // Specify a content encoding if known
-            if (entity.getContentEncoding() != null) {
-                response.setHeader(entity.getContentEncoding()); 
+            if (entity.getContentEncoding() != null && !response.containsHeader(
+                    HTTP.CONTENT_ENCODING)) {
+                response.addHeader(entity.getContentEncoding()); 
             }
         } else {
             int status = response.getStatusLine().getStatusCode();



Mime
View raw message