hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r408030 - in /jakarta/httpcomponents/httpcore/trunk/src: examples/org/apache/http/examples/ElementalHttpServer.java java/org/apache/http/protocol/HttpService.java
Date Sat, 20 May 2006 16:55:01 GMT
Author: olegk
Date: Sat May 20 09:55:00 2006
New Revision: 408030

URL: http://svn.apache.org/viewvc?rev=408030&view=rev
Log:
Corrected mistake from my previous patch. Moved destrory() call to the Thread#run() where
it is meant to be

Modified:
    jakarta/httpcomponents/httpcore/trunk/src/examples/org/apache/http/examples/ElementalHttpServer.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/HttpService.java

Modified: jakarta/httpcomponents/httpcore/trunk/src/examples/org/apache/http/examples/ElementalHttpServer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/examples/org/apache/http/examples/ElementalHttpServer.java?rev=408030&r1=408029&r2=408030&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/examples/org/apache/http/examples/ElementalHttpServer.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/src/examples/org/apache/http/examples/ElementalHttpServer.java
Sat May 20 09:55:00 2006
@@ -180,8 +180,12 @@
         
         public void run() {
             System.out.println("New connection thread");
-            while (!Thread.interrupted() && this.httpservice.isActive()) {
-                this.httpservice.handleRequest();
+            try {
+                while (!Thread.interrupted() && !this.httpservice.isDestroyed() &&
this.httpservice.isActive()) {
+                    this.httpservice.handleRequest();
+                }
+            } finally {
+                this.httpservice.destroy();
             }
         }
 

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/HttpService.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/HttpService.java?rev=408030&r1=408029&r2=408030&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/HttpService.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/HttpService.java
Sat May 20 09:55:00 2006
@@ -101,65 +101,65 @@
         BasicHttpResponse response = new BasicHttpResponse();
         response.getParams().setDefaults(this.params);
         try {
-            try {
-                HttpRequest request = this.conn.receiveRequestHeader(this.params);
-                if (request instanceof HttpEntityEnclosingRequest) {
-                    if (((HttpEntityEnclosingRequest) request).expectContinue()) {
+            HttpRequest request = this.conn.receiveRequestHeader(this.params);
+            if (request instanceof HttpEntityEnclosingRequest) {
+                if (((HttpEntityEnclosingRequest) request).expectContinue()) {
 
-                        logMessage("Expected 100 (Continue)");
-                        
-                        BasicHttpResponse ack = new BasicHttpResponse();
-                        ack.getParams().setDefaults(this.params);
-                        ack.setStatusCode(HttpStatus.SC_CONTINUE);
-                        this.conn.sendResponseHeader(ack);
-                        this.conn.flush();
-                    }
-                    this.conn.receiveRequestEntity((HttpEntityEnclosingRequest) request);
+                    logMessage("Expected 100 (Continue)");
+                    
+                    BasicHttpResponse ack = new BasicHttpResponse();
+                    ack.getParams().setDefaults(this.params);
+                    ack.setStatusCode(HttpStatus.SC_CONTINUE);
+                    this.conn.sendResponseHeader(ack);
+                    this.conn.flush();
                 }
-                preprocessRequest(request, this.context);
-                logMessage("Request received");
-                
-                this.context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
-                this.context.setAttribute(HttpExecutionContext.HTTP_RESPONSE, response);
-                doService(request, response);
-                
-                if (request instanceof HttpEntityEnclosingRequest) {
-                    // Make sure the request content is fully consumed
-                    HttpEntity entity = ((HttpEntityEnclosingRequest)request).getEntity();
-                    if (entity != null) {
-                        entity.consumeContent();
-                    }
-                }
-                
-                postprocessResponse(response, this.context);
-            } catch (ConnectionClosedException ex) {
-                logMessage("Client closed connection");
-                return;
-            } catch (HttpException ex) {
-                handleException(ex, response);
-            } catch (IOException ex) {
-                logIOException(ex);
-                return;
-            }
-            try {
-                this.conn.sendResponseHeader(response);
-                this.conn.sendResponseEntity(response);
-                this.conn.flush();
-                logMessage("Response sent");
-            } catch (HttpException ex) {
-                logProtocolException(ex);
-                return;
-            } catch (IOException ex) {
-                logIOException(ex);
-                return;
+                this.conn.receiveRequestEntity((HttpEntityEnclosingRequest) request);
             }
-            if (!this.connStrategy.keepAlive(response)) {
-                closeConnection();
-            } else {
-                logMessage("Connection kept alive");
+            preprocessRequest(request, this.context);
+            logMessage("Request received");
+            
+            this.context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
+            this.context.setAttribute(HttpExecutionContext.HTTP_RESPONSE, response);
+            doService(request, response);
+            
+            if (request instanceof HttpEntityEnclosingRequest) {
+                // Make sure the request content is fully consumed
+                HttpEntity entity = ((HttpEntityEnclosingRequest)request).getEntity();
+                if (entity != null) {
+                    entity.consumeContent();
+                }
             }
-        } finally {
-            destroy();
+            
+            postprocessResponse(response, this.context);
+        } catch (ConnectionClosedException ex) {
+            logMessage("Client closed connection");
+            closeConnection();
+            return;
+        } catch (HttpException ex) {
+            handleException(ex, response);
+        } catch (IOException ex) {
+            logIOException(ex);
+            closeConnection();
+            return;
+        }
+        try {
+            this.conn.sendResponseHeader(response);
+            this.conn.sendResponseEntity(response);
+            this.conn.flush();
+            logMessage("Response sent");
+        } catch (HttpException ex) {
+            logProtocolException(ex);
+            closeConnection();
+            return;
+        } catch (IOException ex) {
+            logIOException(ex);
+            closeConnection();
+            return;
+        }
+        if (!this.connStrategy.keepAlive(response)) {
+            closeConnection();
+        } else {
+            logMessage("Connection kept alive");
         }
     }
     



Mime
View raw message