commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Can't set User-Agent header
Date Sat, 05 Jan 2002 06:42:29 GMT

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: " +

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.


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)
Adds a default User-Agent request header,
 as long as no User-Agent request header
 already exists.

_________________________________________________________________ Solutions for Your Life 
Check out the most exciting women's community on the Web

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

View raw message