commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ot...@ivillage.com
Subject Can't set User-Agent header
Date Sat, 05 Jan 2002 06:42:29 GMT
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:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message