You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Jesus M. Salvo Jr." <je...@migasia.com> on 2003/03/12 01:03:19 UTC

Bug? HttpMethod.removeRequestHeader( "User-Agent" ) does not remove the header

When I call:

    HttpMethod.removeRequestHeader( "User-Agent" ) ;

... the header is not removed and the value is 
"Jakarta-Commons-HttpClient ..." based on the packet capture that I have 
done.
If I call:

    HttpMethod.setRequestHeader( "User-Agent", null ) ;

... the header is there without any value.
If I call:

    HttpMethod.setRequestHeader( "User-Agent", null ) ;
    HttpMethod.removeRequestHeader( "User-Agent" ) ;

... the User-Agent header is again not removed and the value is 
"Jakarta-Commons-Httpclient .. .blah"




Re: Bug? HttpMethod.removeRequestHeader( "User-Agent" ) does not remove the header

Posted by Sylwester Lachiewicz <ma...@plusnet.pl>.
ok, i know that version should be in HttpClient Request, but i need 
create new User-Agent header with my program version and httpclient 
version eg.
User-Agent: MySuperProgram/1.0 HttpClient/2.0beta3
Its possible to add public static field in file like HttpClient.java and 
use to create UserAgent?

Oleg Kalnichevski wrote:

>Hi Sylwester
>'User-Agent' header should include version information in case you are
>using a release. If you are using a CVS snapshot, there's usually no
>reliable way of telling. Simply stay current 
>Oleg
>
>On Thu, 2003-03-13 at 10:33, Sylwester Lachiewicz wrote:
>  
>
>>Hi,
>>Simple question - how i can get HttpClient version?
>>
>>Sylwester
>>
>>    
>>


Re: Bug? HttpMethod.removeRequestHeader( "User-Agent" ) does not remove the header

Posted by Oleg Kalnichevski <o....@dplanet.ch>.
Hi Sylwester
'User-Agent' header should include version information in case you are
using a release. If you are using a CVS snapshot, there's usually no
reliable way of telling. Simply stay current 
Oleg

On Thu, 2003-03-13 at 10:33, Sylwester Lachiewicz wrote:
> Hi,
> Simple question - how i can get HttpClient version?
> 
> Sylwester
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
> 


Re: Bug? HttpMethod.removeRequestHeader( "User-Agent" ) does not remove the header

Posted by Sylwester Lachiewicz <ma...@plusnet.pl>.
Hi,
Simple question - how i can get HttpClient version?

Sylwester


Re: Bug? HttpMethod.removeRequestHeader( "User-Agent" ) does not remove the header

Posted by Oleg Kalnichevski <o....@dplanet.ch>.
Mike,
Of course, the users should be able to do silly things if they insist.
But do not think we should actively participate. I find current
HttpClieet's behavior correct. At the same time, I could live with a
patch 
Oleg
 
On Wed, 2003-03-12 at 20:48, Michael Becke wrote:
> > This makes sense from an internal point of view, but from a user's 
> > perspective it's kind of weird: You call removeRequestHeader and it 
> > doesn't get removed.  I was wondering if we should modify HttpMethodBase 
> > so that it adds the default User-Agent header in the constructor and in 
> > recycle() instead.  That way, removeRequestHeader would work.
> > 
> > If folks think this is a good idea, I'll submit a patch.
> 
> My only concern is that a method should contain a User-Agent header, 
> according to the RFC. If people don't see this as such a big deal then I 
> say go for it.
> 
> Mike
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
> 


Re: Bug? HttpMethod.removeRequestHeader( "User-Agent" ) does not remove the header

Posted by Michael Becke <be...@u.washington.edu>.
> This makes sense from an internal point of view, but from a user's 
> perspective it's kind of weird: You call removeRequestHeader and it 
> doesn't get removed.  I was wondering if we should modify HttpMethodBase 
> so that it adds the default User-Agent header in the constructor and in 
> recycle() instead.  That way, removeRequestHeader would work.
> 
> If folks think this is a good idea, I'll submit a patch.

My only concern is that a method should contain a User-Agent header, 
according to the RFC. If people don't see this as such a big deal then I 
say go for it.

Mike


Re: Bug? HttpMethod.removeRequestHeader( "User-Agent" ) does not remove the header

Posted by Laura Werner <la...@lwerner.org>.
Michael Becke wrote:

> If the User-Agent header is null the default value is used (take a 
> look at HttpMethodBase.addUserAgentRequestHeaderfrom the system 
> property "httpclient.useragent" and defaults to "Jakarta 
> Commons-HttpClient/2.0alpha3".  To change this value you should either 
> set the "httpclient.useragent" system property or set the User-Agent 
> header to something other than null.

This makes sense from an internal point of view, but from a user's 
perspective it's kind of weird: You call removeRequestHeader and it 
doesn't get removed.  I was wondering if we should modify HttpMethodBase 
so that it adds the default User-Agent header in the constructor and in 
recycle() instead.  That way, removeRequestHeader would work.

If folks think this is a good idea, I'll submit a patch.

Laura Werner
BeVocal


Re: Bug? HttpMethod.removeRequestHeader( "User-Agent" ) does not remove the header

Posted by Michael Becke <be...@u.washington.edu>.
If the User-Agent header is null the default value is used (take a look 
at HttpMethodBase.addUserAgentRequestHeader()).  This value is loaded 
from the system property "httpclient.useragent" and defaults to 
"Jakarta Commons-HttpClient/2.0alpha3".  To change this value you 
should either set the "httpclient.useragent" system property or set the 
User-Agent header to something other than null.

Mike

On Tuesday, March 11, 2003, at 07:03 PM, Jesus M. Salvo Jr. wrote:

>
> When I call:
>
>    HttpMethod.removeRequestHeader( "User-Agent" ) ;
>
> ... the header is not removed and the value is 
> "Jakarta-Commons-HttpClient ..." based on the packet capture that I 
> have done.
> If I call:
>
>    HttpMethod.setRequestHeader( "User-Agent", null ) ;
>
> ... the header is there without any value.
> If I call:
>
>    HttpMethod.setRequestHeader( "User-Agent", null ) ;
>    HttpMethod.removeRequestHeader( "User-Agent" ) ;
>
> ... the User-Agent header is again not removed and the value is 
> "Jakarta-Commons-Httpclient .. .blah"
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: 
> commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: 
> commons-httpclient-dev-help@jakarta.apache.org
>