[prev in list] [next in list] [prev in thread] [next in thread]
List: httpcomponents-commits
Subject: svn commit: r408024 -
From: olegk () apache ! org
Date: 2006-05-20 16:33:44
Message-ID: 20060520163344.861761A983A () eris ! apache ! org
[Download RAW message or body]
Author: olegk
Date: Sat May 20 09:33:42 2006
New Revision: 408024
URL: http://svn.apache.org/viewvc?rev=408024&view=rev
Log:
Added destory method to HttpService
Modified:
jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/HttpService.java
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=408024&r1=408023&r2=408024&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:33:42 2006 @@ -61,6 +61,8 @@
private final HttpServerConnection conn;
private final ConnectionReuseStrategy connStrategy;
private final HttpContext context;
+
+ private volatile boolean destroyed = false;
private HttpParams params = null;
@@ -86,7 +88,7 @@
return this.conn.isOpen();
}
- private void closeConnection() {
+ protected void closeConnection() {
try {
this.conn.close();
} catch (IOException ex) {
@@ -99,65 +101,65 @@
BasicHttpResponse response = new BasicHttpResponse();
response.getParams().setDefaults(this.params);
try {
- HttpRequest request = this.conn.receiveRequestHeader(this.params);
- if (request instanceof HttpEntityEnclosingRequest) {
- if (((HttpEntityEnclosingRequest) request).expectContinue()) {
+ try {
+ 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();
+ 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); }
- this.conn.receiveRequestEntity((HttpEntityEnclosingRequest) \
request);
- }
- 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();
+ 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;
}
-
- 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");
+ 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;
+ }
+ if (!this.connStrategy.keepAlive(response)) {
+ closeConnection();
+ } else {
+ logMessage("Connection kept alive");
+ }
+ } finally {
+ destroy();
}
}
@@ -191,4 +193,14 @@
protected void logProtocolException(final HttpException ex) {
}
+
+ public void destroy() {
+ this.destroyed = true;
+ closeConnection();
+ }
+
+ public boolean isDestroyed() {
+ return this.destroyed;
+ }
+
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic