hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r357460 - in /jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl: DefaultHttpClientConnection.java DefaultHttpServerConnection.java
Date Sun, 18 Dec 2005 12:02:14 GMT
Author: olegk
Date: Sun Dec 18 04:02:06 2005
New Revision: 357460

URL: http://svn.apache.org/viewcvs?rev=357460&view=rev
Log:
Reuse entity generators and entity writers

Modified:
    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

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=357460&r1=357459&r2=357460&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
Sun Dec 18 04:02:06 2005
@@ -78,7 +78,10 @@
     /*
      * Dependent interfaces
      */
-    private HttpResponseFactory responsefactory = null; 
+    private HttpResponseFactory responsefactory = null;
+    private EntityGenerator entitygen = null;
+    private EntityWriter entitywriter = null;
+    private ResponseStrategy responsestrategy = null;
     
     public DefaultHttpClientConnection(final HttpHost targethost, final InetAddress localAddress)
{
         super();
@@ -86,6 +89,9 @@
         this.localAddress = localAddress;
         this.buffer = new CharArrayBuffer(64);
         this.responsefactory = new DefaultHttpResponseFactory();
+        this.entitygen = new DefaultEntityGenerator();
+        this.entitywriter = new DefaultClientEntityWriter();
+        this.responsestrategy = new DefaultResponseStrategy();
     }
     
     public DefaultHttpClientConnection(final HttpHost targethost) {
@@ -218,8 +224,7 @@
         if (request.getEntity() == null) {
             return;
         }
-        EntityWriter entitywriter = new DefaultClientEntityWriter();
-        entitywriter.write(
+        this.entitywriter.write(
                 request.getEntity(),
                 request.getRequestLine().getHttpVersion(),
                 this.datatransmitter);
@@ -256,8 +261,7 @@
         this.datareceiver.reset(params);
         HttpMutableResponse response = readResponseStatusLine(params);
         readResponseHeaders(response);
-        ResponseStrategy responsestrategy = new DefaultResponseStrategy();
-        if (responsestrategy.canHaveEntity(null, response)) {
+        if (this.responsestrategy.canHaveEntity(null, response)) {
             readResponseBody(response);
         }
         return response;
@@ -343,8 +347,7 @@
         
     protected void readResponseBody(
             final HttpMutableResponse response) throws HttpException, IOException {
-        EntityGenerator entitygen = new DefaultEntityGenerator();
-        HttpMutableEntity entity = entitygen.generate(this.datareceiver, response);
+        HttpMutableEntity entity = this.entitygen.generate(this.datareceiver, response);
         // if there is a result - ALWAYS wrap it in an observer which will
         // close the underlying stream as soon as it is consumed, and notify
         // the watcher that the stream has been consumed.

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=357460&r1=357459&r2=357460&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
Sun Dec 18 04:02:06 2005
@@ -63,17 +63,21 @@
 public class DefaultHttpServerConnection 
         extends AbstractHttpConnection implements HttpServerConnection {
 
+    private final CharArrayBuffer buffer; 
+    
     /*
      * Dependent interfaces
      */
     private HttpRequestFactory requestfactory = null; 
+    private EntityGenerator entitygen = null;
+    private EntityWriter entitywriter = null;
 
-    private final CharArrayBuffer buffer; 
-        
     public DefaultHttpServerConnection() {
         super();
         this.requestfactory = new DefaultHttpRequestFactory();
         this.buffer = new CharArrayBuffer(128);
+        this.entitygen = new DefaultEntityGenerator();
+        this.entitywriter = new DefaultServerEntityWriter();
     }
     
     public void setRequestFactory(final HttpRequestFactory requestfactory) {
@@ -135,8 +139,7 @@
 
     protected void receiveRequestBody(final HttpMutableEntityEnclosingRequest request)
             throws HttpException, IOException {
-        EntityGenerator entitygen = new DefaultEntityGenerator();
-        HttpMutableEntity entity = entitygen.generate(this.datareceiver, request);
+        HttpMutableEntity entity = this.entitygen.generate(this.datareceiver, request);
         request.setEntity(entity);
     }
     
@@ -188,8 +191,7 @@
         if (response.getEntity() == null) {
             return;
         }
-        EntityWriter entitywriter = new DefaultServerEntityWriter();
-        entitywriter.write(
+        this.entitywriter.write(
                 response.getEntity(),
                 response.getStatusLine().getHttpVersion(),
                 this.datatransmitter);



Mime
View raw message