I figured out what I believe is the issue... the response coming into the server is 1.0; however, on this line, I'm generating a 1.1 response:
HttpUriRequest statusRequest = statusChecker.generateRequest(data); The HttpAsyncServiceHandler is seeing the 1.1 response and not closing the connection. So the question is (and I cannot find this in the spec), what should a server do which receives 1.0 but can handle 1.1? I would think that it should respond with 1.1, but act as though it's 1.0 so the client knows it can "upgrade" to 1.1 if able. Is this a bug in the components library? Should HttpAsyncServiceHandler be smart enough to "pair-up" a 1.0 request to a 1.1 response and close the connection? I realize that is a lot of state to carry around, and probably isn't wanted. Thoughts? Thanks... Bill- On Wed, Nov 16, 2011 at 4:25 PM, Bill Speirs <[email protected]> wrote: > 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]
