users@glassfish.java.net

Http write timeout & chunked encoding can corrupt proxy cache

From: Maison Mo <momaison_at_yahoo.fr>
Date: Mon, 5 Aug 2013 14:04:54 +0100 (BST)

Hello GF users,

I encounter a problem with a caching proxy (in front of GF 3.1.2.2), in case the first client request times out and transfer is chunked.
From my observations, it appears that GF correctly detects client hangs [ from GF point of view it is a write timeout ; note that the effective value -- default = 2 minutes -- is equal to the configuration value multiplied by 4 ; see grizzly OutputWriter.flushChannel() ], but in any case it finishes the chunked stream nicely (with the ChunkedOutputFilter.END_CHUNK = "0\r\n\r\n").
- This might create a problem for the client, if it is still connected, as it will receive a truncated resource.
- But it is a real problem for all intermediate proxy cache servers, as in any case they will cache a truncated copy of the resource (because nothing is wrong from their point of view : http response is well formed).

I tried to modify my code (not closing servlet outputStream, in hope it would not send END_CHUNK) but did not succeed.
I have harvested the web on this topic without any result. Is this a known bug ? How can it be avoided ?

Thank you for your feedback,

  M.