You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ot...@ivillage.com on 2002/01/05 07:42:29 UTC

Can't set User-Agent header

Hello,

I am trying to set the User-Agent request header by calling setRequestHeader(name, value) on an instance of GetMethod, like this:

_httpMethod.setRequestHeader(name, value);

However, if I enable httpclient.wire logging I see that the User-Agent header sent is actually the default one:

INFO  [Thread-0] httpclient.wire - >> "User-Agent: Jakarta HTTP Client/2.0.0a1
": 05 Jan 2002 00:53:04,334

How do I go about setting value for the User-Agent header?

I also tried this:
_httpMethod.setRequestHeader(new Header(name, value));

That didn't work either.

I have also done this, right after setting the header (above):

System.out.println("User-Agent Header: " +
_httpMethod.getRequestHeader("User-Agent").getValue());


While this does print the User-Agent header that I set, I verified that the User-Agent used in the actual request is that default one that I listed above.

Thanks,
Otis

P.S.
HttpMethodBase has this method, but it's protected and the javadoc indicates that it is not really what I need.

protected void addUserAgentRequestHeader(HttpState�state,
                                         HttpConnection�conn)
                                  throws java.io.IOException,
                                         HttpException
Adds a default User-Agent request header,
 as long as no User-Agent request header
 already exists.

_________________________________________________________________
iVillage.com: Solutions for Your Life 
Check out the most exciting women's community on the Web   
http://www.ivillage.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>