commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rodney Waldhoff" <>
Subject Re: HTTP Client API comment and Q about HttpException
Date Mon, 03 Dec 2001 01:20:30 GMT
>To get the value of a HTTP response header (e.g. 'text/html' part in 
>'Content-type: text/html' header) I have to do this:
>Header header = .... header.getValues()[0].getName();
>Wouldn't it make more sense to call getValue() instead of getName()?

Yes, and you can. What you want is:

Header header = ....

The getValues() approach will coincidentally work but is provided to handle 
a more complex case, namely when a header has multiple (typically semi-colon 
separated) elements.  An example may help clarify:

(this is from memory, but I'm pretty sure it's accurate)


Set-Cookie: cname=cvalue;path=/;;secure

then header.getValue() will  return:


but header.getValues() will return an array of 4 HeaderElements:

header.getValues()[0].getName() => cname
header.getValues()[0].getValue() => cvalue
header.getValues()[1].getName() => path
header.getValues()[1].getValue() => /
header.getValues()[2].getName() => domain
header.getValues()[2].getValue() =>
header.getValues()[3].getName() => secure
header.getValues()[3].getValue() => null

>Also, it looks like HTTP Client is super strict and throws HttpException 
>when it encounters responses such as

>200 OK [...]

>What is it not getting that it needs?

I'm guessing that it is the "Reason-Phrase" part of the "Status-Line" 
production, which may be strictly required by the RFC, but I'd agree that we 
shouldn't choke on its absence.  That's a bug, I'll try to address it in the 

- Rod

Get your FREE download of MSN Explorer at

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message