hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r369023 - in /jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol: AbstractHttpProcessor.java HttpRequestExecutor.java HttpService.java
Date Sat, 14 Jan 2006 13:36:41 GMT
Author: olegk
Date: Sat Jan 14 05:36:29 2006
New Revision: 369023

URL: http://svn.apache.org/viewcvs?rev=369023&view=rev
Log:
AbstractHttpProcessor no longer maintains a local HttpContext internally. An HttpContext instance
is meant to be provided by concrete sub-classes

Contribured by Roland Weber
Reviewed by Oleg Kalnichevski

Modified:
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/AbstractHttpProcessor.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/HttpRequestExecutor.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/HttpService.java

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/AbstractHttpProcessor.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/AbstractHttpProcessor.java?rev=369023&r1=369022&r2=369023&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/AbstractHttpProcessor.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/AbstractHttpProcessor.java
Sat Jan 14 05:36:29 2006
@@ -51,16 +51,9 @@
  */
 public abstract class AbstractHttpProcessor {
 
-    private final HttpContext localContext;
-    
     private List requestInterceptors = null; 
     private List responseInterceptors = null; 
     
-    public AbstractHttpProcessor(final HttpContext localContext) {
-        super();
-        this.localContext = localContext;
-    }
-    
     public void addInterceptor(final HttpRequestInterceptor interceptor) {
         if (interceptor == null) {
             return;
@@ -132,28 +125,27 @@
         this.responseInterceptors = null;
     }
     
-    protected void preprocessRequest(final HttpMutableRequest request) 
-            throws IOException, HttpException {
+    protected void preprocessRequest(
+            final HttpMutableRequest request,
+            final HttpContext context) throws IOException, HttpException {
         if (this.requestInterceptors != null) {
             for (int i = 0; i < this.requestInterceptors.size(); i++) {
                 HttpRequestInterceptor interceptor = (HttpRequestInterceptor) this.requestInterceptors.get(i);
-                interceptor.process(request, this.localContext);
+                interceptor.process(request, context);
             }
         }
     }
 
-    protected void postprocessResponse(final HttpMutableResponse response) 
+    protected void postprocessResponse(
+            final HttpMutableResponse response,
+            final HttpContext context) 
             throws IOException, HttpException {
         if (this.responseInterceptors != null) {
             for (int i = 0; i < this.responseInterceptors.size(); i++) {
                 HttpResponseInterceptor interceptor = (HttpResponseInterceptor) this.responseInterceptors.get(i);
-                interceptor.process(response, this.localContext);
+                interceptor.process(response, context);
             }
         }
-    }
-    
-    protected HttpContext getContext() {
-    	return this.localContext;
     }
     
 }

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/HttpRequestExecutor.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/HttpRequestExecutor.java?rev=369023&r1=369022&r2=369023&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/HttpRequestExecutor.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/HttpRequestExecutor.java
Sat Jan 14 05:36:29 2006
@@ -57,11 +57,14 @@
 
     private static final int WAIT_FOR_CONTINUE_MS = 10000;
     
+    private final HttpContext context;
+    
     private HttpParams params = null;
     private HttpRequestRetryHandler retryhandler = null;
     
     public HttpRequestExecutor(final HttpContext parentContext) {
-        super(new HttpExecutionContext(parentContext));
+        super();
+        this.context = new HttpExecutionContext(parentContext);
     }
     
     public HttpRequestExecutor() {
@@ -91,7 +94,7 @@
             final HttpRequest request, final HttpClientConnection conn)
                 throws IOException, HttpException {
         HttpMutableResponse response = null;
-        getContext().setAttribute(HttpExecutionContext.HTTP_REQ_SENT, 
+        this.context.setAttribute(HttpExecutionContext.HTTP_REQ_SENT, 
                 new Boolean(false));
         // Send request header
         conn.sendRequestHeader(request);
@@ -121,7 +124,7 @@
         }
         conn.flush();
         
-        getContext().setAttribute(HttpExecutionContext.HTTP_REQ_SENT, 
+        this.context.setAttribute(HttpExecutionContext.HTTP_REQ_SENT, 
                 new Boolean(true)); 
         for (;;) {
             // Loop until non 1xx resposne is received
@@ -146,17 +149,16 @@
         if (conn == null) {
             throw new IllegalArgumentException("Client connection may not be null");
         }
-        HttpContext localContext = getContext();
-        localContext.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
-        localContext.setAttribute(HttpExecutionContext.HTTP_CONNECTION, conn);
-        localContext.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST, 
+        this.context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
+        this.context.setAttribute(HttpExecutionContext.HTTP_CONNECTION, conn);
+        this.context.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST, 
         		conn.getTargetHost());
 
         // Link own parameters as defaults 
         request.getParams().setDefaults(this.params);
         
         if (request instanceof HttpMutableRequest) {
-            preprocessRequest((HttpMutableRequest)request);
+            preprocessRequest((HttpMutableRequest)request, this.context);
         }
         
         HttpMutableResponse response = null;
@@ -192,7 +194,7 @@
                 throw ex;
             }
         }
-        postprocessResponse(response);
+        postprocessResponse(response, this.context);
         return response;
     }
 }

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/HttpService.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/HttpService.java?rev=369023&r1=369022&r2=369023&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/HttpService.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/HttpService.java
Sat Jan 14 05:36:29 2006
@@ -61,16 +61,18 @@
 
     private final HttpServerConnection conn;
     private final ConnectionReuseStrategy connStrategy;
+    private final HttpContext context;
     
     private HttpParams params = null;
 
     public HttpService(final HttpServerConnection conn) {
-        super(new HttpExecutionContext(null));
+        super();
         if (conn == null) {
             throw new IllegalArgumentException("HTTP server connection may not be null");
         }
         this.conn = conn;
         this.connStrategy = new DefaultConnectionReuseStrategy();
+        this.context = new HttpExecutionContext(null);
     }
 
     public HttpParams getParams() {
@@ -94,8 +96,7 @@
     }
             
     public void handleRequest() { 
-        HttpContext localContext = getContext();
-        localContext.setAttribute(HttpExecutionContext.HTTP_CONNECTION, this.conn);
+        this.context.setAttribute(HttpExecutionContext.HTTP_CONNECTION, this.conn);
         BasicHttpResponse response = new BasicHttpResponse();
         response.getParams().setDefaults(this.params);
         try {
@@ -113,11 +114,11 @@
                 }
                 this.conn.receiveRequestEntity((HttpMutableEntityEnclosingRequest) request);
             }
-            preprocessRequest(request);
+            preprocessRequest(request, this.context);
             logMessage("Request received");
             
-            localContext.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
-            localContext.setAttribute(HttpExecutionContext.HTTP_RESPONSE, response);
+            this.context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
+            this.context.setAttribute(HttpExecutionContext.HTTP_RESPONSE, response);
             doService(request, response);
             
             if (request instanceof HttpEntityEnclosingRequest) {
@@ -128,7 +129,7 @@
                 }
             }
             
-            postprocessResponse(response);
+            postprocessResponse(response, this.context);
         } catch (ConnectionClosedException ex) {
             logMessage("Client closed connection");
             closeConnection();



Mime
View raw message