Possible error in implementationofReplayingDecoderBuffer::readableBytes() causing empty HTTP200OK response to be always chunked
Pankaj Bathwal
pankaj.bathwal at agnity.com
Sat Jul 3 15:26:03 EDT 2010
Hi,
I am not sure if it is issue with understanding or problem in
ReplayingDecoderBuffer::readableBytes().
Can someone look into this small piece of code?
Thanks,
Pankaj
_____
From: netty-users-bounces at lists.jboss.org
[mailto:netty-users-bounces at lists.jboss.org] On Behalf Of Pankaj Bathwal
Sent: Friday, July 02, 2010 2:41 AM
To: 'Netty Users'; trustin at gmail.com
Subject: RE: Possible error in
implementationofReplayingDecoderBuffer::readableBytes() causing empty
HTTP200OK response to be always chunked
Hi,
Has anyone tried this kind of scenario where we have empty 200 OK response
and they are using HTTP decoder.
Has anyone looked into ReplayingDecoderBuffe issue?
Thanks,
Pankaj
_____
From: netty-users-bounces at lists.jboss.org
[mailto:netty-users-bounces at lists.jboss.org] On Behalf Of Pankaj Bathwal
Sent: Wednesday, June 30, 2010 7:45 PM
To: 'Netty Users'; trustin at gmail.com
Subject: Possible error in implementation
ofReplayingDecoderBuffer::readableBytes() causing empty HTTP 200OK response
to be always chunked
Hi,
Greetings.
I am using Netty 3.1.5.
Empty "200 OK" response received without any content length and without
"Content-length" header is received as chunked response in the response
handler (HttpsResponseHandler:: messageReceived of
org.jboss.netty.example.http.snoop).
Following is my findings:
In the class "class ReplayingDecoderBuffer implements ChannelBuffer"
function "readableBytes()" is implemented as given below:
//The function below will return size more than maxChunkSize most of the
time.
public int readableBytes() {
if (terminated) {
return buffer.readableBytes();
} else {
return Integer.MAX_VALUE - buffer.readerIndex();
}
}
But in Interface ChannelBuffer, following is documented as definition of
function "readableBytes()"
/**
* Returns the number of readable bytes which is equal to
* {@code (this.writerIndex - this.readerIndex)}.
*/
Int readableBytes();
As a result of above implementation of
ReplayingDecoderBuffer::readableBytes(),
when a "200 OK" response comes without any content length and without
"Content-length" header
HTTP response decoder function (HttpMessageDecoder:: decode) function set
the value of "Transfer-Encoding" header to "chunked".
HttpMessageDecoder.java:line no - 206)
CODE below from HttpMessageDecoder.java :
case READ_VARIABLE_LENGTH_CONTENT:
if (buffer.readableBytes() > maxChunkSize) {
// Generate HttpMessage first. HttpChunks will
follow.
checkpoint(State.READ_VARIABLE_LENGTH_CONTENT_AS_CHUNKS);
message.addHeader(HttpHeaders.Names.TRANSFER_ENCODING,
HttpHeaders.Values.CHUNKED);
return message;
}
break;
}
This is causing HTTP response Handler to wait to next chunk even if there is
no chunk coming from the network.
Please let me know if my understanding if correct and there is an issue in
"ReplayingDecoderBuffer::readableBytes()".
Or do kindly let me know if I am doing anything wrong that my empty response
is always chunked.
Thanks,
Pankaj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20100704/e709b0e2/attachment-0001.html
More information about the netty-users
mailing list