412712 - HttpClient does not send the terminal chunk after partial writes.

HttpGenerator._header and HttpGenerator._buffer may be null when
the content is written after a partial write.
In this case, the terminal chunk was not prepared, and therefore never
written.

The fix simply creates a HttpGenerator._header to prepare the terminal
chunk, so that it will be written.
This commit is contained in:
Simone Bordet 2013-07-10 22:57:23 +02:00
parent cb0084260f
commit 8eb6649709
1 changed files with 5 additions and 2 deletions

View File

@ -1015,14 +1015,17 @@ public class HttpGenerator extends AbstractGenerator
// If we need EOC and everything written
if (_needEOC && (_content == null || _content.length() == 0))
{
if (_header == null && _buffer == null)
_header = _buffers.getHeader();
if (_needCRLF)
{
if (_buffer == null && _header != null && _header.space() >= 2)
if (_buffer == null && _header != null && _header.space() >= HttpTokens.CRLF.length)
{
_header.put(HttpTokens.CRLF);
_needCRLF = false;
}
else if (_buffer!=null && _buffer.space() >= 2)
else if (_buffer!=null && _buffer.space() >= HttpTokens.CRLF.length)
{
_buffer.put(HttpTokens.CRLF);
_needCRLF = false;