hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r385789 - in /jakarta/httpcomponents/trunk/http-core/src: java/org/apache/http/ java/org/apache/http/entity/ java/org/apache/http/impl/ java/org/apache/http/impl/entity/ java/org/apache/http/message/ test/org/apache/http/mockup/
Date Tue, 14 Mar 2006 11:24:10 GMT
Author: olegk
Date: Tue Mar 14 03:24:05 2006
New Revision: 385789

URL: http://svn.apache.org/viewcvs?rev=385789&view=rev
Log:
* Added getHttpVersion() method to HttpMessage interface
* Changed parameter signature of the EntitySerializer#write method

Added:
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/AbstractHttpMessage.java
      - copied, changed from r385290, jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/BasicHttpMessage.java
Removed:
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/BasicHttpMessage.java
Modified:
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpMessage.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/EntitySerializer.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/DefaultHttpClientConnection.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/DefaultHttpServerConnection.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultClientEntitySerializer.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultServerEntitySerializer.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/BasicHttpRequest.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/BasicHttpResponse.java
    jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/mockup/HttpMessageMockup.java

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpMessage.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpMessage.java?rev=385789&r1=385788&r2=385789&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpMessage.java (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpMessage.java Tue Mar
14 03:24:05 2006
@@ -44,6 +44,8 @@
  * @since 4.0
  */
 public interface HttpMessage {
+    
+    public HttpVersion getHttpVersion();
 
     boolean containsHeader(String name);
     

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/EntitySerializer.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/EntitySerializer.java?rev=385789&r1=385788&r2=385789&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/EntitySerializer.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/entity/EntitySerializer.java
Tue Mar 14 03:24:05 2006
@@ -33,7 +33,7 @@
 
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpException;
-import org.apache.http.HttpVersion;
+import org.apache.http.HttpMessage;
 import org.apache.http.io.HttpDataTransmitter;
 
 /**
@@ -48,8 +48,8 @@
 public interface EntitySerializer {
 
     void write(
-            HttpEntity entity,
-            HttpVersion version,
-            HttpDataTransmitter datatransmitter) throws HttpException, IOException;
+            HttpDataTransmitter datatransmitter,
+            HttpMessage message,
+            HttpEntity entity) throws HttpException, IOException;
             
 }

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/DefaultHttpClientConnection.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/DefaultHttpClientConnection.java?rev=385789&r1=385788&r2=385789&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/DefaultHttpClientConnection.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/DefaultHttpClientConnection.java
Tue Mar 14 03:24:05 2006
@@ -181,9 +181,9 @@
             return;
         }
         this.entityserializer.write(
-                request.getEntity(),
-                request.getRequestLine().getHttpVersion(),
-                this.datatransmitter);
+                this.datatransmitter,
+                request,
+                request.getEntity());
     }
 
     public void flush() throws IOException {

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/DefaultHttpServerConnection.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/DefaultHttpServerConnection.java?rev=385789&r1=385788&r2=385789&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/DefaultHttpServerConnection.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/DefaultHttpServerConnection.java
Tue Mar 14 03:24:05 2006
@@ -167,9 +167,9 @@
             return;
         }
         this.entityserializer.write(
-                response.getEntity(),
-                response.getStatusLine().getHttpVersion(),
-                this.datatransmitter);
+                this.datatransmitter,
+                response,
+                response.getEntity());
     }
     
     protected void sendResponseStatusLine(final HttpResponse response) 

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultClientEntitySerializer.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultClientEntitySerializer.java?rev=385789&r1=385788&r2=385789&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultClientEntitySerializer.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultClientEntitySerializer.java
Tue Mar 14 03:24:05 2006
@@ -34,6 +34,7 @@
 
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpException;
+import org.apache.http.HttpMessage;
 import org.apache.http.HttpVersion;
 import org.apache.http.ProtocolException;
 import org.apache.http.entity.EntitySerializer;
@@ -57,23 +58,23 @@
     }
 
     public void write(
-            final HttpEntity entity,
-            final HttpVersion version,
-            final HttpDataTransmitter datatransmitter) throws HttpException, IOException
{
-        if (entity == null) {
-            throw new IllegalArgumentException("HTTP entity may not be null");
-        }
-        if (version == null) {
-            throw new IllegalArgumentException("HTTP version may not be null");
-        }
+            final HttpDataTransmitter datatransmitter,
+            final HttpMessage message,
+            final HttpEntity entity) throws HttpException, IOException {
         if (datatransmitter == null) {
             throw new IllegalArgumentException("HTTP data transmitter may not be null");
         }
+        if (message == null) {
+            throw new IllegalArgumentException("HTTP message may not be null");
+        }
+        if (entity == null) {
+            throw new IllegalArgumentException("HTTP entity may not be null");
+        }
         long len = entity.getContentLength();
         boolean chunked = entity.isChunked() || len < 0;  
-        if (chunked && version.lessEquals(HttpVersion.HTTP_1_0)) {
+        if (chunked && message.getHttpVersion().lessEquals(HttpVersion.HTTP_1_0))
{
             throw new ProtocolException(
-                    "Chunked transfer encoding not supported by " + version);
+                    "Chunked transfer encoding not supported by " + message.getHttpVersion());
         }
         OutputStream outstream = null;
         if (chunked) {

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultServerEntitySerializer.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultServerEntitySerializer.java?rev=385789&r1=385788&r2=385789&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultServerEntitySerializer.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/entity/DefaultServerEntitySerializer.java
Tue Mar 14 03:24:05 2006
@@ -34,6 +34,7 @@
 
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpException;
+import org.apache.http.HttpMessage;
 import org.apache.http.HttpVersion;
 import org.apache.http.entity.EntitySerializer;
 import org.apache.http.io.ChunkedOutputStream;
@@ -57,21 +58,21 @@
     }
 
     public void write(
-            final HttpEntity entity,
-            final HttpVersion version,
-            final HttpDataTransmitter datatransmitter) throws HttpException, IOException
{
-        if (entity == null) {
-            throw new IllegalArgumentException("HTTP entity may not be null");
-        }
-        if (version == null) {
-            throw new IllegalArgumentException("HTTP version may not be null");
-        }
+            final HttpDataTransmitter datatransmitter,
+            final HttpMessage message,
+            final HttpEntity entity) throws HttpException, IOException {
         if (datatransmitter == null) {
             throw new IllegalArgumentException("HTTP data transmitter may not be null");
         }
+        if (message == null) {
+            throw new IllegalArgumentException("HTTP message may not be null");
+        }
+        if (entity == null) {
+            throw new IllegalArgumentException("HTTP entity may not be null");
+        }
         OutputStream outstream = null;
         long len = entity.getContentLength();
-        if (entity.isChunked() && version.greaterEquals(HttpVersion.HTTP_1_1)) {
+        if (entity.isChunked() && message.getHttpVersion().greaterEquals(HttpVersion.HTTP_1_1))
{
             outstream = new ChunkedOutputStream(datatransmitter);
         } else if (len >= 0) {
             outstream = new ContentLengthOutputStream(datatransmitter, len);

Copied: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/AbstractHttpMessage.java
(from r385290, jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/BasicHttpMessage.java)
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/AbstractHttpMessage.java?p2=jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/AbstractHttpMessage.java&p1=jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/BasicHttpMessage.java&r1=385290&r2=385789&rev=385789&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/BasicHttpMessage.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/AbstractHttpMessage.java
Tue Mar 14 03:24:05 2006
@@ -46,13 +46,13 @@
  * 
  * @since 4.0
  */
-public class BasicHttpMessage implements HttpMessage {
+public abstract class AbstractHttpMessage implements HttpMessage {
     
     private final HeaderGroup headergroup;
     
     private HttpParams params = null;
     
-    protected BasicHttpMessage() {
+    protected AbstractHttpMessage() {
         super();
         this.headergroup = new HeaderGroup();
         this.params = new DefaultHttpParams(null);

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/BasicHttpRequest.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/BasicHttpRequest.java?rev=385789&r1=385788&r2=385789&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/BasicHttpRequest.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/BasicHttpRequest.java
Tue Mar 14 03:24:05 2006
@@ -43,7 +43,7 @@
  * 
  * @since 4.0
  */
-public class BasicHttpRequest extends BasicHttpMessage implements HttpRequest {
+public class BasicHttpRequest extends AbstractHttpMessage implements HttpRequest {
     
     private final RequestLine requestline;
     private final String method;
@@ -72,6 +72,14 @@
         this.uri = requestline.getUri();
     }
 
+    public HttpVersion getHttpVersion() {
+        if (this.requestline != null) {
+            return this.requestline.getHttpVersion();
+        } else {
+            return HttpProtocolParams.getVersion(getParams());
+        }
+    }
+    
     public RequestLine getRequestLine() {
         if (this.requestline != null) {
             return this.requestline;
@@ -80,4 +88,5 @@
             return new RequestLine(this.method, this.uri, ver);
         }
     }
+    
 }

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/BasicHttpResponse.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/BasicHttpResponse.java?rev=385789&r1=385788&r2=385789&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/BasicHttpResponse.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/message/BasicHttpResponse.java
Tue Mar 14 03:24:05 2006
@@ -32,6 +32,7 @@
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
+import org.apache.http.HttpVersion;
 import org.apache.http.StatusLine;
 import org.apache.http.params.HttpProtocolParams;
 
@@ -44,7 +45,7 @@
  * 
  * @since 4.0
  */
-public class BasicHttpResponse extends BasicHttpMessage implements HttpResponse {
+public class BasicHttpResponse extends AbstractHttpMessage implements HttpResponse {
     
     private StatusLine statusline = null;
     private HttpEntity entity = null;
@@ -59,6 +60,10 @@
         setStatusLine(statusline);
     }
 
+    public HttpVersion getHttpVersion() {
+        return this.statusline.getHttpVersion();
+    }
+    
     public StatusLine getStatusLine() {
         return this.statusline; 
     }

Modified: jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/mockup/HttpMessageMockup.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/mockup/HttpMessageMockup.java?rev=385789&r1=385788&r2=385789&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/mockup/HttpMessageMockup.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/mockup/HttpMessageMockup.java
Tue Mar 14 03:24:05 2006
@@ -29,17 +29,23 @@
 
 package org.apache.http.mockup;
 
-import org.apache.http.message.BasicHttpMessage;
+import org.apache.http.HttpVersion;
+import org.apache.http.message.AbstractHttpMessage;
+import org.apache.http.params.HttpProtocolParams;
 
 /**
  *  {@link HttpMessage} mockup implementation.
  *  
  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  */
-public class HttpMessageMockup extends BasicHttpMessage {
+public class HttpMessageMockup extends AbstractHttpMessage {
     
     public HttpMessageMockup() {
         super();
     }
 
+    public HttpVersion getHttpVersion() {
+        return (HttpVersion) this.getParams().getParameter(HttpProtocolParams.PROTOCOL_VERSION);
+    }
+    
 }



Mime
View raw message