I would suggest to test for the Transfer-Encoding Header. If it's there wrap it in a limiting stream otherwise as already implemented?