Bug 62977 - Allow sending HTTP requests without a default User-Agent header
Summary: Allow sending HTTP requests without a default User-Agent header
Status: RESOLVED FIXED
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: HTTP (show other bugs)
Version: 5.0
Hardware: All All
: P3 enhancement (vote)
Target Milestone: JMETER_5.1.1
Assignee: JMeter issues mailing list
URL: https://issues.apache.org/jira/browse...
Keywords: FixedInTrunk
Depends on:
Blocks:
 
Reported: 2018-12-04 06:26 UTC by Antony Bowesman
Modified: 2019-03-09 16:01 UTC (History)
3 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Antony Bowesman 2018-12-04 06:26:44 UTC
Using a HeaderManager for the request, if you do not add a User-Agent header, one is automatically added by default, like 

User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_102)

If I try specifying an empty UA header in the header manager, it sends the empty header.

In the deprecated org.apache.http.impl.client.DefaultHttpClient, it sets the defaults for the connection and the problem appears that there is no way to override those defaults so that no UA header is sent as it adds that default UA header if there is no UA in the request.

A lot of current testing is not testing websites, so this header is pretty redundant for a lot of traffic, e.e. in a micro service architecture environment.
Comment 1 Michael Osipov 2018-12-04 16:07:44 UTC
This header is by default added from our Apache HttpClient. I checked the source code, there is currently no way of disabling this. Even if you invoke HttpClentBuilder#setUserAgent(null), it'd overridden with the default one. The only workaround I see is to call HttpClentBuilder#addInterceptorLast(HttpRequestInterceptor) which would remove this header actively. This could be done from JMeter with a JMeter property. I'd prefer a reasonable solution in HttpClient directly, e.g., HttpClentBuilder#disableDefaultUserAgent().

Please a issue with https://issues.apache.org/jira/browse/HTTPCLIENT.
Comment 2 Antony Bowesman 2018-12-05 07:44:13 UTC
https://issues.apache.org/jira/browse/HTTPCLIENT-1952
Comment 3 Michael Osipov 2018-12-05 13:05:18 UTC
As soon as the upstream ticket is resolved we can introduce a system property to disable this header.
Comment 4 Philippe Mouawad 2018-12-05 17:33:51 UTC
Hello,

What about considering that empty value for Header means "remove header" ?

Regards
Comment 5 Antony Bowesman 2018-12-05 21:00:15 UTC
An empty header is a valid use case. The ABNF in RFC7230 also defines the field value as

field-value = *( field-content / obs-fold )

which would indicate that empty values are valid.
Comment 6 Philippe Mouawad 2018-12-23 22:25:10 UTC
Issue fixed in httpclient 4.5.7
Comment 7 Michael Osipov 2018-12-24 00:08:37 UTC
(In reply to Philippe Mouawad from comment #6)
> Issue fixed in httpclient 4.5.7

Boy, you are fast. You must have been lurking for my merge ;-)
Comment 8 Philippe Mouawad 2018-12-24 10:47:47 UTC
(In reply to Michael Osipov from comment #7)
> (In reply to Philippe Mouawad from comment #6)
> > Issue fixed in httpclient 4.5.7
> 
> Boy, you are fast. You must have been lurking for my merge ;-)

Hello Michael,

They call me Lucky Luke, the man who comments before his shadow :-)

On an another topic, the 4.5.7 would not be released before Q1, we'll probably be releasing a JMeter 5.1 before without any possibility to fix this issue.

Regards
Comment 9 Michael Osipov 2018-12-24 12:38:00 UTC
(In reply to Philippe Mouawad from comment #8)
> (In reply to Michael Osipov from comment #7)
> > (In reply to Philippe Mouawad from comment #6)
> > > Issue fixed in httpclient 4.5.7
> > 
> > Boy, you are fast. You must have been lurking for my merge ;-)
> 
> Hello Michael,
> 
> They call me Lucky Luke, the man who comments before his shadow :-)
> 
> On an another topic, the 4.5.7 would not be released before Q1, we'll
> probably be releasing a JMeter 5.1 before without any possibility to fix
> this issue.
> 
> Regards

You should kindly request on the dev mailing list release for Jan. I guess neither Oleg noch Gary will mind. This is an important issue.
Comment 10 Philippe Mouawad 2018-12-24 12:41:00 UTC
(In reply to Michael Osipov from comment #9)
> (In reply to Philippe Mouawad from comment #8)
> > (In reply to Michael Osipov from comment #7)
> > > (In reply to Philippe Mouawad from comment #6)
> > > > Issue fixed in httpclient 4.5.7
> > > 
> > > Boy, you are fast. You must have been lurking for my merge ;-)
> > 
> > Hello Michael,
> > 
> > They call me Lucky Luke, the man who comments before his shadow :-)
> > 
> > On an another topic, the 4.5.7 would not be released before Q1, we'll
> > probably be releasing a JMeter 5.1 before without any possibility to fix
> > this issue.
> > 
> > Regards
> 
> You should kindly request on the dev mailing list release for Jan. I guess
> neither Oleg noch Gary will mind. This is an important issue.

Hello Michael,
Already done for another issue .

You can have a look at mailing list.
Regards
Comment 11 Philippe Mouawad 2019-03-03 10:20:19 UTC
Author: pmouawad
Date: Sun Mar  3 10:19:20 2019
New Revision: 1854682

URL: http://svn.apache.org/viewvc?rev=1854682&view=rev
Log:
Bug 62977 - Unable to send HTTP requests without a User-Agent header
Bugzilla Id: 62977

Modified:
    jmeter/trunk/bin/jmeter.properties
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/properties_reference.xml
Comment 12 The ASF infrastructure team 2022-09-24 20:38:15 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/4940