mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-18 16:07:11 +00:00
[HTTPCLIENT-1952] Allow default User Agent to be disabled
This closes #128
This commit is contained in:
parent
bf18e7d04e
commit
354ae3586e
@ -229,6 +229,7 @@ private ExecInterceptorEntry(
|
|||||||
private boolean cookieManagementDisabled;
|
private boolean cookieManagementDisabled;
|
||||||
private boolean authCachingDisabled;
|
private boolean authCachingDisabled;
|
||||||
private boolean connectionStateDisabled;
|
private boolean connectionStateDisabled;
|
||||||
|
private boolean defaultUserAgentDisabled;
|
||||||
|
|
||||||
private List<Closeable> closeables;
|
private List<Closeable> closeables;
|
||||||
|
|
||||||
@ -697,6 +698,16 @@ public final HttpClientBuilder evictIdleConnections(final TimeValue maxIdleTime)
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables the default user agent set by this builder if none has been provided by the user.
|
||||||
|
*
|
||||||
|
* @since 4.5.7
|
||||||
|
*/
|
||||||
|
public final HttpClientBuilder disableDefaultUserAgent() {
|
||||||
|
this.defaultUserAgentDisabled = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request exec chain customization and extension.
|
* Request exec chain customization and extension.
|
||||||
* <p>
|
* <p>
|
||||||
@ -779,7 +790,7 @@ public boolean keepAlive(
|
|||||||
if (systemProperties) {
|
if (systemProperties) {
|
||||||
userAgentCopy = System.getProperty("http.agent");
|
userAgentCopy = System.getProperty("http.agent");
|
||||||
}
|
}
|
||||||
if (userAgentCopy == null) {
|
if (userAgentCopy == null && !defaultUserAgentDisabled) {
|
||||||
userAgentCopy = VersionInfo.getSoftwareInfo("Apache-HttpClient",
|
userAgentCopy = VersionInfo.getSoftwareInfo("Apache-HttpClient",
|
||||||
"org.apache.hc.client5", getClass());
|
"org.apache.hc.client5", getClass());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user