hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r232391 - /jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java
Date Fri, 12 Aug 2005 20:56:28 GMT
Author: olegk
Date: Fri Aug 12 13:56:25 2005
New Revision: 232391

URL: http://svn.apache.org/viewcvs?rev=232391&view=rev
Log:
Minor bug fixes

Modified:
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.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=232391&r1=232390&r2=232391&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
Fri Aug 12 13:56:25 2005
@@ -155,8 +155,11 @@
                         receiveHttpRequest();
                         prepareCoyoteRequest();
                         callServletContainer();
-                        prepareHttpResponse();
-                        sendHttpResponse();
+                        if (!this.coyoteres.isCommitted()) {
+                            prepareHttpResponse();
+                            sendHttpResponse();
+                            this.coyoteres.setCommitted(true);
+                        }
                         closeOutputBuffer();
                     	manageHttpConnection();
                         reset();
@@ -201,26 +204,28 @@
         getContext().setAttribute(HttpProcessingContext.HTTP_REQUEST, this.httpreq);
     }
 
+    private HttpMutableResponse createResponse(int status) {
+        HttpVersion ver = this.httpreq.getRequestLine().getHttpVersion();
+        BasicHttpResponse response = new BasicHttpResponse(new StatusLine(ver, status));
+    	response.getParams().setDefaults(this.httpreq.getParams());
+    	return response;
+    }
+    
     private HttpResponse processHttpException(final HttpException ex) {
     	LOG.debug("Processing HTTP exception");
-    	HttpMutableResponse response = new BasicHttpResponse();
-    	response.getParams().setDefaults(this.params);
         if (ex instanceof MethodNotSupportedException) {
-            response.setStatusCode(HttpStatus.SC_NOT_IMPLEMENTED);
+            return createResponse(HttpStatus.SC_NOT_IMPLEMENTED);
         } else if (ex instanceof ProtocolException) {
-            response.setStatusCode(HttpStatus.SC_BAD_REQUEST);
+        	return createResponse(HttpStatus.SC_BAD_REQUEST);
         } else {
-            response.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+        	return createResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR);
         }
-        return response;
     }
 
     private void sendAck() throws IOException {
     	if (this.httpreq instanceof HttpEntityEnclosingRequest) {
     		if (((HttpEntityEnclosingRequest)this.httpreq).expectContinue()) {
-    	        HttpVersion ver = this.httpreq.getRequestLine().getHttpVersion();
-    	        BasicHttpResponse ack = new BasicHttpResponse(
-    	        		new StatusLine(ver, HttpStatus.SC_CONTINUE));
+    	        HttpResponse ack = createResponse(HttpStatus.SC_CONTINUE);
     	        try {
     	            this.conn.sendResponse(ack);
     	            LOG.debug("Ack continue sent");



Mime
View raw message