fix handling of chunked requests