You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Vishal_Jain <pi...@gmail.com> on 2007/12/05 07:33:01 UTC

Re: AsyncHttpClient with no content-length header

Is there a JIRA id for this issue ? 
or any workarounds ?

vishal


berdim99 wrote:
> 
> Hi.
> It seems that AsyncHttpClient fails to decode a web page in which the
> web-server doesn't send a content-length header.
> What happens is that the callback is called with a null content, after
> which the decoder throws an exception because it thinks that the rest of
> the incoming data are of a new HTTP response (but they are actually the
> previous response content).
> (Such web site is http://www.toptable.co.uk/).
> 
> Any help is appreciated.
> Micha.
> 

-- 
View this message in context: http://www.nabble.com/AsyncHttpClient-with-no-content-length-header-tf4723565s16868.html#a14166028
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: AsyncHttpClient with no content-length header

Posted by Vishal_Jain <pi...@gmail.com>.
disregard the change i mentioned in the previous post .. it won't help. Since
there is no CRLF at the end of Body.
We would need a Decoding state that reads till session close. I couldn't
find a suitable Decoding state present (am new to  the code and thats why
perhaps could have overlooked something)

vishal


Vishal_Jain wrote:
> 
> Should we modify the
> org.apache.mina.filter.codec.http.HttpResponseDecodingState line 215 from
> nextState = null
> to
> nextState = new ConsumeToCrLfDecodingState(){
>                         @Override
>                         protected DecodingState finishDecode(IoBuffer
> readData,
>                                 ProtocolDecoderOutput out) throws
> Exception {
>                             response.setContent(readData);
>                             out.write(response);
>                             return null;
>                         }
>                     };
> 
> ?
> 
> am just guessing, perhaps someone with good understanding of the code can
> fix it better.
> 
> vishal
> 
> 
> 
> Vishal_Jain wrote:
>> 
>> Is there a JIRA id for this issue ? 
>> or any workarounds ?
>> 
>> vishal
>> 
>> 
>> berdim99 wrote:
>>> 
>>> Hi.
>>> It seems that AsyncHttpClient fails to decode a web page in which the
>>> web-server doesn't send a content-length header.
>>> What happens is that the callback is called with a null content, after
>>> which the decoder throws an exception because it thinks that the rest of
>>> the incoming data are of a new HTTP response (but they are actually the
>>> previous response content).
>>> (Such web site is http://www.toptable.co.uk/).
>>> 
>>> Any help is appreciated.
>>> Micha.
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/AsyncHttpClient-with-no-content-length-header-tf4723565s16868.html#a14167644
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: AsyncHttpClient with no content-length header

Posted by Vishal_Jain <pi...@gmail.com>.
Should we modify the
org.apache.mina.filter.codec.http.HttpResponseDecodingState line 215 from
nextState = null
to
nextState = new ConsumeToCrLfDecodingState(){
                        @Override
                        protected DecodingState finishDecode(IoBuffer
readData,
                                ProtocolDecoderOutput out) throws Exception
{
                            response.setContent(readData);
                            out.write(response);
                            return null;
                        }
                    };

?

am just guessing, perhaps someone with good understanding of the code can
fix it better.

vishal



Vishal_Jain wrote:
> 
> Is there a JIRA id for this issue ? 
> or any workarounds ?
> 
> vishal
> 
> 
> berdim99 wrote:
>> 
>> Hi.
>> It seems that AsyncHttpClient fails to decode a web page in which the
>> web-server doesn't send a content-length header.
>> What happens is that the callback is called with a null content, after
>> which the decoder throws an exception because it thinks that the rest of
>> the incoming data are of a new HTTP response (but they are actually the
>> previous response content).
>> (Such web site is http://www.toptable.co.uk/).
>> 
>> Any help is appreciated.
>> Micha.
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/AsyncHttpClient-with-no-content-length-header-tf4723565s16868.html#a14166396
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: AsyncHttpClient with no content-length header

Posted by Vishal_Jain <pi...@gmail.com>.
Thanks Jeff.
have raised a JIRA. https://issues.apache.org/jira/browse/DIRMINA-487

While it is being fixed, is there anything i can look at to fix the issue
(even if temporarily)  ?
would really appreciate if someone can help me work out a fix.

vishal


jgenender wrote:
> 
> Yes, please open a JIRA on this.  According to the HTTP spec, anything
> with content should have a content line.  However, there does appear to
> be a site that is not compliant (http://www.toptable.co.uk/) and
> probably more... thus we could fall back to reading until there is no
> more data.  However, this concerns me as a possible buffer/memory
> problem (it would then be easy to crash a Mina client).  Anyone have an
> opinion on this?
> 
> Jeff
> 
> Vishal_Jain wrote:
>> Is there a JIRA id for this issue ? 
>> or any workarounds ?
>> 
>> vishal
>> 
>> 
>> berdim99 wrote:
>>> Hi.
>>> It seems that AsyncHttpClient fails to decode a web page in which the
>>> web-server doesn't send a content-length header.
>>> What happens is that the callback is called with a null content, after
>>> which the decoder throws an exception because it thinks that the rest of
>>> the incoming data are of a new HTTP response (but they are actually the
>>> previous response content).
>>> (Such web site is http://www.toptable.co.uk/).
>>>
>>> Any help is appreciated.
>>> Micha.
>>>
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/AsyncHttpClient-with-no-content-length-header-tf4723565s16868.html#a14173229
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: AsyncHttpClient with no content-length header

Posted by Jeff Genender <jg...@apache.org>.
Yes, please open a JIRA on this.  According to the HTTP spec, anything
with content should have a content line.  However, there does appear to
be a site that is not compliant (http://www.toptable.co.uk/) and
probably more... thus we could fall back to reading until there is no
more data.  However, this concerns me as a possible buffer/memory
problem (it would then be easy to crash a Mina client).  Anyone have an
opinion on this?

Jeff

Vishal_Jain wrote:
> Is there a JIRA id for this issue ? 
> or any workarounds ?
> 
> vishal
> 
> 
> berdim99 wrote:
>> Hi.
>> It seems that AsyncHttpClient fails to decode a web page in which the
>> web-server doesn't send a content-length header.
>> What happens is that the callback is called with a null content, after
>> which the decoder throws an exception because it thinks that the rest of
>> the incoming data are of a new HTTP response (but they are actually the
>> previous response content).
>> (Such web site is http://www.toptable.co.uk/).
>>
>> Any help is appreciated.
>> Micha.
>>
>