I am having an issue with an HttpAsyncRequestHandler<HttpRequest>
leaving the connection to a client open after sending the data to the
client for an HTTP 1.0 (no keep-alive) request. Here is a sample of
the request:
[wspeirs]$ telnet localhost 57144
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /statusCheck HTTP/1.0
User-Agent: test
Host: localhost:57144
Accept: */*
HTTP/1.1 200 OK
Content-Type: text/plain
Date: Wed, 16 Nov 2011 21:11:14 GMT
Server: Proxy
Content-Length: 7
SUCCESS<- connection remains open here
This is the code I'm using to handle the request and send back the
response made via the Async client:
public Cancellable handle(HttpRequest data, final
HttpAsyncResponseTrigger trigger, HttpContext context) throws
HttpException, IOException {
HttpUriRequest statusRequest = statusChecker.generateRequest(data);
// execute the request, and trigger the response when it arrives
httpClient.execute(statusRequest, new FutureCallback<HttpResponse>() {
public void completed(final HttpResponse response) {
trigger.submitResponse(new
BasicAsyncResponseProducer(statusChecker.processResponse(response)));
}
public void failed(final Exception ex) {
BasicHttpResponse errResponse = new
BasicHttpResponse(HttpVersion.HTTP_1_0, 0, null);
HttpUtils.generateResponse(errResponse,
StatusCode.SERVER_ERROR);
trigger.submitResponse(new
BasicAsyncResponseProducer(errResponse));
}
public void cancelled() {
BasicHttpResponse errResponse = new
BasicHttpResponse(HttpVersion.HTTP_1_0, 0, null);
HttpUtils.generateResponse(errResponse,
StatusCode.TIMEOUT);
trigger.submitResponse(new
BasicAsyncResponseProducer(errResponse));
}
});
return null;
}
When setting up my HttpAsyncServiceHandler, I set
ImmutableHttpProcessors, one of which is ResponseConnControl():
HttpProcessor httpproc = new ImmutableHttpProcessor(new
HttpResponseInterceptor[] {
new ResponseDate(),
new ResponseServer(),
new ResponseContent(),
new ResponseConnControl()
});
this.handlerRegistry = new HttpAsyncRequestHandlerRegistry();
//
create a new registry for the resolvers
this.handler = new HttpAsyncServiceHandler(handlerRegistry,
httpproc,
new DefaultConnectionReuseStrategy(),
params);
Why is the server leaving the connections open? How to I tell it to
close the connection after sending all of the data for HTTP 1.0
requests?
Thanks in advance...
Bill-
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]