You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by becks007 <an...@ca.com> on 2012/03/07 12:29:29 UTC

CoreConnectionPNames.MAX_LINE_LENGTH processing

Folks,

My query is regarding the what is desired behavior of
CoreConnectionPNames.MAX_LINE_LENGTH.

I had set the params.setIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH,
100) and I see that those headers larger than 100 is getting added to the
response headers.

Further looking into to the code i figured out that it is only handled for a
folded headers. This is an HttpClient specific setting isn't it? I checked
the documentation as well there is nothing mentioned about the behavior for
folded headers.

*********************************************************************
org.apache.http.impl.AbstractHttpServerConnection.receiveRequestHeader()
  org.apache.http.impl.io.AbstractMessageParser.parse()
   
org.apache.http.impl.io.AbstractMessageParser.parseHeaders(SessionInputBuffer,
int, int, LineParser, List)


        // Parse the header name and value
        // Check for folded headers first
        // Detect LWS-char see HTTP/1.0 or HTTP/1.1 Section 2.2
        // discussion on folded headers
        if ((current.charAt(0) == ' ' || current.charAt(0) == '\t') &&
previous != null) {
           ....

                if (maxLineLen > 0
                        && previous.length() + 1 + current.length() - i >
maxLineLen) {
                    throw new IOException("Maximum line length limit
exceeded");

           ....
        }

-- 
View this message in context: http://old.nabble.com/CoreConnectionPNames.MAX_LINE_LENGTH-processing-tp33457329p33457329.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: CoreConnectionPNames.MAX_LINE_LENGTH processing

Posted by becks007 <an...@ca.com>.
Thanks Oleg,

Yes, I go to trace that out. Seems there is a return statement in the while
loop which makes it to skip that length check.


                if (this.linebuffer.isEmpty()) {
                    // the entire line is preset in the read buffer
                    return lineFromReadBuffer(charbuffer, i);
                }

I will open an issue for this.

Regards
bekz


olegk wrote:
> 
> On Wed, 2012-03-07 at 09:46 -0800, becks007 wrote:
>> Thanks Oleg,
>> 
>> I think java doc is accurate :) I am not sure if there is anything wrong
>> with my program. But i was using 4.2.1 and observed that MAX_LINE_LENGTH
>> is
>> not applied to single lines and headers having larger values than
>> configured
>> max line length was getting populated. 
>> 
>> In the earlier code snippet i had pasted i see that max line length is
>> only
>> checked for folded headers if so that needs  a patch; i will try to open
>> up
>> a defect and give the patch if so.
>> 
> 
> Length of individual lines is checked in the
> AbstractSessionInputBuffer#readLine, but feel free to double-check and
> raise a defect in JIRA if in some cases the max length is not properly
> enforced. 
> 
> http://hc.apache.org/httpcomponents-core-ga/httpcore/xref/org/apache/http/impl/io/AbstractSessionInputBuffer.html#238
> 
> Oleg
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 
> 
> 
-- 
View this message in context: http://old.nabble.com/CoreConnectionPNames.MAX_LINE_LENGTH-processing-tp33457329p33460709.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: CoreConnectionPNames.MAX_LINE_LENGTH processing

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2012-03-07 at 09:46 -0800, becks007 wrote:
> Thanks Oleg,
> 
> I think java doc is accurate :) I am not sure if there is anything wrong
> with my program. But i was using 4.2.1 and observed that MAX_LINE_LENGTH is
> not applied to single lines and headers having larger values than configured
> max line length was getting populated. 
> 
> In the earlier code snippet i had pasted i see that max line length is only
> checked for folded headers if so that needs  a patch; i will try to open up
> a defect and give the patch if so.
> 

Length of individual lines is checked in the
AbstractSessionInputBuffer#readLine, but feel free to double-check and
raise a defect in JIRA if in some cases the max length is not properly
enforced. 

http://hc.apache.org/httpcomponents-core-ga/httpcore/xref/org/apache/http/impl/io/AbstractSessionInputBuffer.html#238

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: CoreConnectionPNames.MAX_LINE_LENGTH processing

Posted by becks007 <an...@ca.com>.
Thanks Oleg,

I think java doc is accurate :) I am not sure if there is anything wrong
with my program. But i was using 4.2.1 and observed that MAX_LINE_LENGTH is
not applied to single lines and headers having larger values than configured
max line length was getting populated. 

In the earlier code snippet i had pasted i see that max line length is only
checked for folded headers if so that needs  a patch; i will try to open up
a defect and give the patch if so.

My intention was to verify the correct behaviour as I am not that well
versed with HTTP specs and all. 

Regards
bekz


olegk wrote:
> 
> CoreConnectionPNames.MAX_LINE_LENGTH should apply to single limes as
> well folded ones.
> 
> I'll happily take a patch for javadocs ;-)
> 
> Oleg 
> 

-- 
View this message in context: http://old.nabble.com/CoreConnectionPNames.MAX_LINE_LENGTH-processing-tp33457329p33459749.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: CoreConnectionPNames.MAX_LINE_LENGTH processing

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2012-03-07 at 03:29 -0800, becks007 wrote:
> Folks,
> 
> My query is regarding the what is desired behavior of
> CoreConnectionPNames.MAX_LINE_LENGTH.
> 
> I had set the params.setIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH,
> 100) and I see that those headers larger than 100 is getting added to the
> response headers.
> 
> Further looking into to the code i figured out that it is only handled for a
> folded headers. This is an HttpClient specific setting isn't it? I checked
> the documentation as well there is nothing mentioned about the behavior for
> folded headers.
> 

CoreConnectionPNames.MAX_LINE_LENGTH should apply to single limes as
well folded ones.

I'll happily take a patch for javadocs ;-)

Oleg 



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org