On Tue, 2008-04-29 at 19:33 +0000, computer junkie wrote:
> Hi all,
>
> I read in something that came from a response. I got the content-type by
> using ..getResponseHeader("content-type");
> I
> want to keep the information about the content type but access very
> often just the type itself. That's why I thought it best to keep it as
> a HeaderElement: That takes care of properly storing any parameters
> (such as charset=...).
>
> so far so good.
>
> Now I want to use this as the content-type header in another message.
> if i do
> addRequestHeader("content-type", myHeaderElement.toString());
> that gives me in the actual message (using firebug to inspect):
> Content-Type: name=application/x-www-form-urlencoded, value=null
>
> oops!
>
> How do I get it in a header properly?
> How do I get it printing out as a String properly (let's say even if not for
> the Header itself) ?
>
> I looked for something like header.addHeaderElement(myHeaderElement) and then
> adding that header. No such luck.
> I also looked for something like HeaderElement.write(myHeaderElement) or
> something like that to mirror HeaderElement.parse ...
> Still nothing.
>
StringBuffer is your friend. Use ParameterFormatter from
org.apache.commons.httpclient.util
to format individual name/value pairs and append them to the buffer.
HttpClient 4.0 has a much better message parsing / formatting API. So,
if you do not mind using ALPHA code, consider using 4.0 API instead.
Oleg
> Help appreciated !
> Thanks!
> Rania
> _________________________________________________________________
> News, entertainment and everything you care about at Live.com. Get it now!
> http://www.live.com/getstarted.aspx
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]