hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r231511 - in /jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl: HttpConnectionProcessor.java HttpProcessingContext.java
Date Thu, 11 Aug 2005 20:46:54 GMT
Author: olegk
Date: Thu Aug 11 13:46:50 2005
New Revision: 231511

URL: http://svn.apache.org/viewcvs?rev=231511&view=rev
Log:
Added some of the required response interceptors to the Coyote HTTP processor

Modified:
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpProcessingContext.java

Modified: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java?rev=231511&r1=231510&r2=231511&view=diff
==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java
(original)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java
Thu Aug 11 13:46:50 2005
@@ -73,6 +73,8 @@
 import org.apache.http.impl.ResponseStrategy;
 import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.AbstractHttpProcessor;
+import org.apache.http.protocol.ResponseConnControl;
+import org.apache.http.protocol.ResponseContent;
 import org.apache.tomcat.util.http.MimeHeaders;
 
 /**
@@ -124,7 +126,12 @@
         this.coyoteres = new Response();
         this.coyoteres.setHook(this);
         this.coyoteres.setRequest(this.coyotereq);
+
+        // Add required protocol interceptors
+        addResponseInterceptor(new ResponseContent());
+        addResponseInterceptor(new ResponseConnControl());
         
+        // Add connection to the HTTP context
         getContext().setAttribute(HttpProcessingContext.HTTP_CONNECTION, conn);
     }
 
@@ -167,10 +174,17 @@
     }
 
     private void receiveHttpRequest() throws IOException, HttpException {
-        this.coyotereq.getRequestProcessor().setStage(Constants.STAGE_PARSE);
+        this.coyotereq.getRequestProcessor().setStage(Constants.STAGE_NEW);
     	this.httpreq = this.conn.receiveRequest(this.params);
         this.coyotereq.setStartTime(System.currentTimeMillis());
         LOG.debug("HTTP request received");
+        this.coyotereq.getRequestProcessor().setStage(Constants.STAGE_PREPARE);
+
+        if (this.httpreq instanceof HttpMutableRequest) {
+        	preprocessRequest((HttpMutableRequest)this.httpreq);
+        }
+        // Add request to the HTTP context
+        getContext().setAttribute(HttpProcessingContext.HTTP_REQUEST, this.httpreq);
     }
 
     private HttpResponse processHttpException(final HttpException ex) {
@@ -184,13 +198,14 @@
         } else {
             response.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
         }
-        response.setHeader(new Header("Server", "Jakarta HttpCommons"));
-        response.setHeader(new Header("Connection", "Close"));
         return response;
     }
         
     private void sendHttpResponse() throws IOException {
     	try {
+            if (this.httpres instanceof HttpMutableResponse) {
+            	postprocessResponse((HttpMutableResponse)this.httpres);
+            }
     		this.conn.sendResponse(this.httpres);
             LOG.debug("HTTP response sent");
     	} catch (HttpException ex) {
@@ -200,13 +215,7 @@
     }
 
     private void prepareCoyoteRequest() throws IOException, HttpException {
-
-    	this.coyotereq.getRequestProcessor().setStage(Constants.STAGE_PREPARE);
-        // Preprocess the request 
-        if (this.httpreq instanceof HttpMutableRequest) {
-        	preprocessRequest((HttpMutableRequest)this.httpreq);
-        }
-
+    	this.coyotereq.getRequestProcessor().setStage(Constants.STAGE_PARSE);
         // Convert the request line
         RequestLine reqline = this.httpreq.getRequestLine();
         HttpVersion ver = reqline.getHttpVersion();
@@ -300,7 +309,7 @@
         }
 	}
 
-    private void prepareHttpResponse() throws IOException, HttpException {
+    private void prepareHttpResponse() throws IOException {
         this.coyotereq.getRequestProcessor().setStage(Constants.STAGE_ENDINPUT);
         if (this.httpres != null) {
             return;
@@ -329,11 +338,6 @@
         	this.coyoteres.setOutputBuffer(buffer);
         }
         this.httpres = tmp;
-
-        // Postprocess the response 
-        if (this.httpres instanceof HttpMutableResponse) {
-        	postprocessResponse((HttpMutableResponse)this.httpres);
-        }
     }
 
     private void manageHttpConnection() throws IOException {

Modified: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpProcessingContext.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpProcessingContext.java?rev=231511&r1=231510&r2=231511&view=diff
==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpProcessingContext.java
(original)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpProcessingContext.java
Thu Aug 11 13:46:50 2005
@@ -45,10 +45,6 @@
  */
 public class HttpProcessingContext implements HttpContext {
     
-    public static final String HTTP_CONNECTION  = "http.connection"; 
-    public static final String HTTP_REQUEST     = "http.request"; 
-    public static final String HTTP_RESPONSE    = "http.response"; 
-    
     private final HttpContext parentContext;
     private Map<String, Object> map = null;
     



Mime
View raw message