users@grizzly.java.net

Closing a single connection while using keep alive

From: Ana Laura Felisatti <anafelisatti_at_gmail.com>
Date: Fri, 5 Jun 2015 17:12:35 -0300

Hi, there.

I was wondering what is the proper or best way to close a connection while
maintaining a general keep alive policy.

We are creating a HttpServerFilter with a KeepAlive, so that connections
are not closed unless they timeout. However, the response we generate could
potentially include a "Connection: close" header, in which case we want the
connection to close when the response is sent.

I tried explicitly closing the connection using the FilterChainContext but
I'm sure that will cause complications. I then tried this with the
HttpResponsePacket we generate and that makes it to the prepareResponse
method of HttpServerFilter:

httpResponsePacket.getProcessingState().setKeepAlive(false);

Is that the proper way?

Thanks,

-- 
Ana Felisatti