commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kedar Panse" <ke...@bancbridge.com>
Subject RE: [HTTPClient] Header parser
Date Sat, 03 Feb 2007 12:34:05 GMT
Actually there is not a new line, it's the same line where the set cookie
header is.
So the line contains:

"Set-Cookie: user-cookie=xxxx; path=/; domain=.xxx.com; secure HTTP/1.0 200"

Which I think makes this invalid. But I read somewhere that server can
choose to change the protocol from HTTP/1.1 to HTTP/1.0 in such cases it can
send two of these headers? I am not quite sure if this is covered under
folded headers thing.


Thanks!


Kedar

-----Original Message-----
From: Bindul Bhowmik [mailto:bindulbhowmik@gmail.com] 
Sent: Saturday, February 03, 2007 3:18 PM
To: Jakarta Commons Users List
Subject: Re: [HTTPClient] Header parser

Kedar,

On 2/3/07, Kedar Panse <kedar@bancbridge.com> wrote:
> Hello guys!
>
>
>
> I have been using HTTPClient for quite a while, thanks to you guys work!
> Recently I came across a site, which I believe is returning bad headers.
> HTTPClient seems to choke on
>
>
>
> Set-Cookie: user-cookie=xxxx; path=/; domain=.xxx.com; secure HTTP/1.0 200

The HTTP/1.0 200 is the status line of the HTTP response and is
supposed to be the first line in the response [1]. HttpClient is
trying to parse that field as a name value HTTP Header.

Also, not evident in the email, I think there is a new line character
between secure and HTTP in that line.

>
> content-type: text/html
>
>
>
> Exception I get is:
>
>
>
> WARNING: org.apache.commons.httpclient.ProtocolException: Unable to parse
> header: HTTP/1.0 200
>
>
>
>
>
> Is this a valid header for cookie?  Firefox/IE seem to get past it easy.
Is
> there any way to get around this?

The way to get around this is to modify the HttpClient source. More
specifically you need to modify the
org.apache.commons.httpclient.HttpParser#readLine(InputStream, String)
method and can make it lenient and ask it to ignore any lines that
dont follow the standard 'header-name: header-value' pattern. You can
modify the source and rebuild your own jar.

I don't know your entire response, but if HttpClient has reached the
state where it is parsing the headers, I assume the server has already
sent a status line as the first line of response.

>
>
>
>
>
> Regards,
>
>
>
> Kedar
>
>

Hope this helps,

Regards,
Bindul

-- 
Bindul Bhowmik
MindTree Consulting Ltd.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message