hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r358842 - in /jakarta/httpcomponents/trunk/http-core/src: examples/org/apache/http/examples/ java/org/apache/http/ java/org/apache/http/entity/ java/org/apache/http/impl/entity/ java/org/apache/http/protocol/ java/org/apache/http/util/ test...
Date Fri, 23 Dec 2005 17:52:06 GMT
Author: olegk
Date: Fri Dec 23 09:51:36 2005
New Revision: 358842

URL: http://svn.apache.org/viewcvs?rev=358842&view=rev
Log:
Changed HttpEntity interface and related classes to allow lazy parsing of the content type
and content encoding headers

Modified:
    jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpEchoServer.java
    jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpPost.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpEntity.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/BasicHttpEntity.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/BufferedHttpEntity.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/ByteArrayEntity.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/FileEntity.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/InputStreamEntity.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/StringEntity.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultEntityGenerator.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/RequestContent.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/ResponseContent.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/util/EntityUtils.java
    jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/entity/TestHttpEntities.java
    jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/util/TestEntityUtils.java

Modified: jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpEchoServer.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpEchoServer.java?rev=358842&r1=358841&r2=358842&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpEchoServer.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpEchoServer.java
Fri Dec 23 09:51:36 2005
@@ -103,7 +103,7 @@
                 buffer.append(entity.isChunked());
                 buffer.append("</p>");
                 if (entity.getContentType() != null 
-                        && entity.getContentType().toLowerCase().startsWith("text/"))
{
+                        && entity.getContentType().getValue().toLowerCase().startsWith("text/"))
{
                     buffer.append("<p>");
                     buffer.append(EntityUtils.toString(entity));
                     buffer.append("</p>");
@@ -136,7 +136,7 @@
                         Long.toString(body.getContentLength())));
             }
             if (body.getContentType() != null) {
-                response.setHeader(new Header("Content-Type", body.getContentType())); 
+                response.setHeader(body.getContentType()); 
             }
             response.setEntity(body);
         }

Modified: jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpPost.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpPost.java?rev=358842&r1=358841&r2=358842&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpPost.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/examples/org/apache/http/examples/ElementalHttpPost.java
Fri Dec 23 09:51:36 2005
@@ -94,7 +94,7 @@
                 }
                 // Specify a content type if known
                 if (requestbody.getContentType() != null) {
-                    request.setHeader(new Header("Content-Type", requestbody.getContentType()));

+                    request.setHeader(requestbody.getContentType()); 
                 }
                 request.setEntity(requestbody);
                 

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpEntity.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpEntity.java?rev=358842&r1=358841&r2=358842&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpEntity.java (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpEntity.java Fri Dec
23 09:51:36 2005
@@ -44,15 +44,18 @@
  */
 public interface HttpEntity {
 
+    public static final String CONTENT_TYPE = "Content-Type";
+    public static final String CONTENT_ENCODING = "Content-Encoding";
+    
     boolean isRepeatable();
 
     boolean isChunked();
 
     long getContentLength();
     
-    String getContentType();
+    Header getContentType();
     
-    String getContentEncoding();
+    Header getContentEncoding();
     
     InputStream getContent() throws IOException;
     

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/BasicHttpEntity.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/BasicHttpEntity.java?rev=358842&r1=358841&r2=358842&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/BasicHttpEntity.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/BasicHttpEntity.java
Fri Dec 23 09:51:36 2005
@@ -33,6 +33,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 
+import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 
 /**
@@ -46,8 +47,8 @@
  */
 public class BasicHttpEntity implements HttpEntity {
     
-    private String contentType = null;
-    private String contentEncoding = null;
+    private Header contentType = null;
+    private Header contentEncoding = null;
     private InputStream content = null;
     private long length = -1;
     private boolean chunked = false;
@@ -60,11 +61,11 @@
         return this.length;
     }
 
-    public String getContentType() {
+    public Header getContentType() {
         return this.contentType;
     }
     
-    public String getContentEncoding() {
+    public Header getContentEncoding() {
         return this.contentEncoding;
     }
     
@@ -88,11 +89,11 @@
         this.length = len;
     }
     
-    public void setContentType(final String contentType) {
+    public void setContentType(final Header contentType) {
         this.contentType = contentType;
     }
     
-    public void setContentEncoding(final String contentEncoding) {
+    public void setContentEncoding(final Header contentEncoding) {
         this.contentEncoding = contentEncoding;
     }
     

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/BufferedHttpEntity.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/BufferedHttpEntity.java?rev=358842&r1=358841&r2=358842&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/BufferedHttpEntity.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/BufferedHttpEntity.java
Fri Dec 23 09:51:36 2005
@@ -34,6 +34,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 
+import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.util.EntityUtils;
 
@@ -72,11 +73,11 @@
         }
     }
 
-    public String getContentType() {
+    public Header getContentType() {
         return this.source.getContentType();
     }
     
-    public String getContentEncoding() {
+    public Header getContentEncoding() {
         return this.source.getContentEncoding();
     }
     

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/ByteArrayEntity.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/ByteArrayEntity.java?rev=358842&r1=358841&r2=358842&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/ByteArrayEntity.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/ByteArrayEntity.java
Fri Dec 23 09:51:36 2005
@@ -34,6 +34,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 
+import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 
 /**
@@ -78,16 +79,24 @@
         return this.content.length;
     }
     
-    public String getContentType() {
-        return this.contentType;
+    public Header getContentType() {
+        if (this.contentType != null) {
+            return new Header(HttpEntity.CONTENT_TYPE, this.contentType);
+        } else {
+            return null;
+        }
     }
 
     public void setContentType(final String contentType) {
         this.contentType = contentType;
     }
 
-    public String getContentEncoding() {
-        return this.contentEncoding;
+    public Header getContentEncoding() {
+        if (this.contentEncoding != null) {
+            return new Header(HttpEntity.CONTENT_ENCODING, this.contentEncoding);
+        } else {
+            return null;
+        }
     }
 
     public void setContentEncoding(final String contentEncoding) {

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/FileEntity.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/FileEntity.java?rev=358842&r1=358841&r2=358842&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/FileEntity.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/FileEntity.java
Fri Dec 23 09:51:36 2005
@@ -1,7 +1,7 @@
 /*
- * $HeadURL: $
- * $Revision: $
- * $Date: $
+ * $HeadURL$
+ * $Revision$
+ * $Date$
  *
  * ====================================================================
  *
@@ -35,6 +35,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 
+import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 
 /**
@@ -42,7 +43,7 @@
  * </p>
  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  *
- * @version $Revision: $
+ * @version $Revision$
  * 
  * @since 4.0
  */
@@ -78,16 +79,24 @@
         return this.file.length();
     }
     
-    public String getContentType() {
-        return this.contentType;
+    public Header getContentType() {
+        if (this.contentType != null) {
+            return new Header(HttpEntity.CONTENT_TYPE, this.contentType);
+        } else {
+            return null;
+        }
     }
 
     public void setContentType(final String contentType) {
         this.contentType = contentType;
     }
 
-    public String getContentEncoding() {
-        return this.contentEncoding;
+    public Header getContentEncoding() {
+        if (this.contentEncoding != null) {
+            return new Header(HttpEntity.CONTENT_ENCODING, this.contentEncoding);
+        } else {
+            return null;
+        }
     }
 
     public void setContentEncoding(final String contentEncoding) {

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/InputStreamEntity.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/InputStreamEntity.java?rev=358842&r1=358841&r2=358842&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/InputStreamEntity.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/InputStreamEntity.java
Fri Dec 23 09:51:36 2005
@@ -33,6 +33,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 
+import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 
 /**
@@ -80,16 +81,24 @@
         return this.length;
     }
     
-    public String getContentType() {
-        return this.contentType;
+    public Header getContentType() {
+        if (this.contentType != null) {
+            return new Header(HttpEntity.CONTENT_TYPE, this.contentType);
+        } else {
+            return null;
+        }
     }
 
     public void setContentType(final String contentType) {
         this.contentType = contentType;
     }
 
-    public String getContentEncoding() {
-        return this.contentEncoding;
+    public Header getContentEncoding() {
+        if (this.contentEncoding != null) {
+            return new Header(HttpEntity.CONTENT_ENCODING, this.contentEncoding);
+        } else {
+            return null;
+        }
     }
 
     public void setContentEncoding(final String contentEncoding) {

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/StringEntity.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/StringEntity.java?rev=358842&r1=358841&r2=358842&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/StringEntity.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/StringEntity.java
Fri Dec 23 09:51:36 2005
@@ -35,6 +35,7 @@
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 
+import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 
 /**
@@ -90,16 +91,24 @@
         return this.content.length;
     }
     
-    public String getContentType() {
-        return this.contentType;
+    public Header getContentType() {
+        if (this.contentType != null) {
+            return new Header(HttpEntity.CONTENT_TYPE, this.contentType);
+        } else {
+            return null;
+        }
     }
 
     public void setContentType(final String contentType) {
         this.contentType = contentType;
     }
 
-    public String getContentEncoding() {
-        return this.contentEncoding;
+    public Header getContentEncoding() {
+        if (this.contentEncoding != null) {
+            return new Header(HttpEntity.CONTENT_ENCODING, this.contentEncoding);
+        } else {
+            return null;
+        }
     }
 
     public void setContentEncoding(final String contentEncoding) {

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultEntityGenerator.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultEntityGenerator.java?rev=358842&r1=358841&r2=358842&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultEntityGenerator.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultEntityGenerator.java
Fri Dec 23 09:51:36 2005
@@ -280,10 +280,10 @@
             entity.setContent(new HttpDataInputStream(datareceiver));                   
        
         }
         if (contentTypeHeader != null) {
-            entity.setContentType(contentTypeHeader.getValue());    
+            entity.setContentType(contentTypeHeader);    
         }
         if (contentEncodingHeader != null) {
-            entity.setContentEncoding(contentEncodingHeader.getValue());    
+            entity.setContentEncoding(contentEncodingHeader);    
         }
         return entity;
     }

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/RequestContent.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/RequestContent.java?rev=358842&r1=358841&r2=358842&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/RequestContent.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/RequestContent.java
Fri Dec 23 09:51:36 2005
@@ -53,7 +53,6 @@
 
     private static final String TRANSFER_ENC = "Transfer-Encoding";
     private static final String CONTENT_LEN  = "Content-Length";
-    private static final String CONTENT_TYPE = "Content-Type";
     
     private static final String CHUNK_CODING = "chunked";
     
@@ -88,7 +87,7 @@
             }
             // Specify a content type if known
             if (entity.getContentType() != null) {
-                request.setHeader(new Header(CONTENT_TYPE, entity.getContentType(), true));

+                request.setHeader(entity.getContentType()); 
             }
         }
     }

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/ResponseContent.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/ResponseContent.java?rev=358842&r1=358841&r2=358842&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/ResponseContent.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/ResponseContent.java
Fri Dec 23 09:51:36 2005
@@ -51,8 +51,6 @@
 
     private static final String TRANSFER_ENC = "Transfer-Encoding";
     private static final String CONTENT_LEN  = "Content-Length";
-    private static final String CONTENT_TYPE = "Content-Type";
-    private static final String CONTENT_ENC = "Content-Encoding";
 
     private static final String CHUNK_CODING = "chunked";
     
@@ -79,11 +77,11 @@
             }
             // Specify a content type if known
             if (entity.getContentType() != null) {
-                response.setHeader(new Header(CONTENT_TYPE, entity.getContentType(), true));

+                response.setHeader(entity.getContentType()); 
             }
             // Specify a content encoding if known
             if (entity.getContentEncoding() != null) {
-                response.setHeader(new Header(CONTENT_ENC, entity.getContentEncoding(), true));

+                response.setHeader(entity.getContentEncoding()); 
             }
         }
     }

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/util/EntityUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/util/EntityUtils.java?rev=358842&r1=358841&r2=358842&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/util/EntityUtils.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/util/EntityUtils.java
Fri Dec 23 09:51:36 2005
@@ -84,7 +84,7 @@
         }
         String charset = null;
         if (entity.getContentType() != null) { 
-            HeaderElement values[] = HeaderElement.parseAll(entity.getContentType());
+            HeaderElement values[] = entity.getContentType().getElements();
             if (values.length > 0) {
                 NameValuePair param = values[0].getParameterByName("charset");
                 if (param != null) {

Modified: jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/entity/TestHttpEntities.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/entity/TestHttpEntities.java?rev=358842&r1=358841&r2=358842&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/entity/TestHttpEntities.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/entity/TestHttpEntities.java
Fri Dec 23 09:51:36 2005
@@ -33,6 +33,9 @@
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
@@ -64,14 +67,16 @@
     	BasicHttpEntity httpentity = new BasicHttpEntity();
     	httpentity.setContent(content);
     	httpentity.setContentLength(bytes.length);
-    	httpentity.setContentType("text/plain");
-    	httpentity.setContentEncoding("identity");
+    	httpentity.setContentType(new Header(HttpEntity.CONTENT_TYPE, "text/plain"));
+    	httpentity.setContentEncoding(new Header(HttpEntity.CONTENT_ENCODING, "identity"));
     	httpentity.setChunked(false);
     	
     	assertEquals(content, httpentity.getContent());
     	assertEquals(bytes.length, httpentity.getContentLength());
-    	assertEquals("text/plain", httpentity.getContentType());
-    	assertEquals("identity", httpentity.getContentEncoding());
+        assertEquals(HttpEntity.CONTENT_TYPE, httpentity.getContentType().getName());
+    	assertEquals("text/plain", httpentity.getContentType().getValue());
+        assertEquals(HttpEntity.CONTENT_ENCODING, httpentity.getContentEncoding().getName());
+    	assertEquals("identity", httpentity.getContentEncoding().getValue());
     	assertFalse(httpentity.isChunked());
     	assertFalse(httpentity.isRepeatable());
     }
@@ -120,8 +125,10 @@
     	httpentity.setChunked(false);
     	
     	assertEquals(bytes.length, httpentity.getContentLength());
-    	assertEquals("application/octet-stream", httpentity.getContentType());
-    	assertEquals("identity", httpentity.getContentEncoding());
+        assertEquals(HttpEntity.CONTENT_TYPE, httpentity.getContentType().getName());
+        assertEquals("application/octet-stream", httpentity.getContentType().getValue());
+        assertEquals(HttpEntity.CONTENT_ENCODING, httpentity.getContentEncoding().getName());
+        assertEquals("identity", httpentity.getContentEncoding().getValue());
     	assertNotNull(httpentity.getContent());
     	assertFalse(httpentity.isChunked());
     	assertTrue(httpentity.isRepeatable());
@@ -175,8 +182,10 @@
         
         byte[] bytes = s.getBytes("ISO-8859-1");
         assertEquals(bytes.length, httpentity.getContentLength());
-        assertEquals("text/plain", httpentity.getContentType());
-        assertEquals("identity", httpentity.getContentEncoding());
+        assertEquals(HttpEntity.CONTENT_TYPE, httpentity.getContentType().getName());
+        assertEquals("text/plain", httpentity.getContentType().getValue());
+        assertEquals(HttpEntity.CONTENT_ENCODING, httpentity.getContentEncoding().getName());
+        assertEquals("identity", httpentity.getContentEncoding().getValue());
         assertNotNull(httpentity.getContent());
         assertFalse(httpentity.isChunked());
         assertTrue(httpentity.isRepeatable());
@@ -195,10 +204,10 @@
         String s = "Message content";
         StringEntity httpentity = new StringEntity(s, "US-ASCII");
         assertEquals("text/plain; charset=US-ASCII", 
-                httpentity.getContentType());
+                httpentity.getContentType().getValue());
         httpentity = new StringEntity(s);
         assertEquals("text/plain; charset=ISO-8859-1", 
-                httpentity.getContentType());
+                httpentity.getContentType().getValue());
     }
 
     public void testStringEntityWriteTo() throws Exception {
@@ -241,8 +250,10 @@
         httpentity.setChunked(false);
         
         assertEquals(bytes.length, httpentity.getContentLength());
-        assertEquals("text/plain", httpentity.getContentType());
-        assertEquals("identity", httpentity.getContentEncoding());
+        assertEquals(HttpEntity.CONTENT_TYPE, httpentity.getContentType().getName());
+        assertEquals("text/plain", httpentity.getContentType().getValue());
+        assertEquals(HttpEntity.CONTENT_ENCODING, httpentity.getContentEncoding().getName());
+        assertEquals("identity", httpentity.getContentEncoding().getValue());
         assertEquals(instream, httpentity.getContent());
         assertNotNull(httpentity.getContent());
         assertFalse(httpentity.isChunked());

Modified: jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/util/TestEntityUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/util/TestEntityUtils.java?rev=358842&r1=358841&r2=358842&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/util/TestEntityUtils.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/util/TestEntityUtils.java
Fri Dec 23 09:51:36 2005
@@ -1,7 +1,7 @@
 /*
- * $HeadURL: $
- * $Revision: $
- * $Date: $
+ * $HeadURL$
+ * $Revision$
+ * $Date$
  * 
  * ====================================================================
  *
@@ -31,6 +31,7 @@
 
 import java.io.ByteArrayInputStream;
 
+import org.apache.http.Header;
 import org.apache.http.entity.BasicHttpEntity;
 
 import junit.framework.Test;
@@ -130,13 +131,13 @@
     
     public void testNoCharsetGetContentCharset() throws Exception {
         BasicHttpEntity httpentity = new BasicHttpEntity();
-        httpentity.setContentType("text/plain; param=yadayada");
+        httpentity.setContentType(new Header("Content-Type", "text/plain; param=yadayada"));
         assertNull(EntityUtils.getContentCharSet(httpentity));
     }
     
     public void testGetContentCharset() throws Exception {
         BasicHttpEntity httpentity = new BasicHttpEntity();
-        httpentity.setContentType("text/plain; charset = UTF-8");
+        httpentity.setContentType(new Header("Content-Type", "text/plain; charset = UTF-8"));
         assertEquals("UTF-8", EntityUtils.getContentCharSet(httpentity));
     }
     
@@ -212,7 +213,7 @@
         byte[] bytes = content.getBytes("ISO-8859-1");
         BasicHttpEntity httpentity = new BasicHttpEntity();
         httpentity.setContent(new ByteArrayInputStream(bytes));
-        httpentity.setContentType("text/plain");
+        httpentity.setContentType(new Header("Content-Type", "text/plain"));
         String s = EntityUtils.toString(httpentity);
         assertEquals(content, s);
     }
@@ -222,7 +223,7 @@
         byte[] bytes = content.getBytes("KOI8-R");
         BasicHttpEntity httpentity = new BasicHttpEntity();
         httpentity.setContent(new ByteArrayInputStream(bytes));
-        httpentity.setContentType("text/plain");
+        httpentity.setContentType(new Header("Content-Type", "text/plain"));
         String s = EntityUtils.toString(httpentity, "KOI8-R");
         assertEquals(content, s);
     }
@@ -232,7 +233,7 @@
         byte[] bytes = content.getBytes("UTF-8");
         BasicHttpEntity httpentity = new BasicHttpEntity();
         httpentity.setContent(new ByteArrayInputStream(bytes));
-        httpentity.setContentType("text/plain; charset=UTF-8");
+        httpentity.setContentType(new Header("Content-Type", "text/plain; charset=UTF-8"));
         String s = EntityUtils.toString(httpentity, "ISO-8859-1");
         assertEquals(content, s);
     }



Mime
View raw message