HTTPCLIENT-1508: use actual JRE version when generating default User-Agent header
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1594805 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0a93660d96
commit
1ba8a897f3
|
@ -47,6 +47,7 @@ import org.apache.http.protocol.RequestContent;
|
|||
import org.apache.http.protocol.RequestExpectContinue;
|
||||
import org.apache.http.protocol.RequestTargetHost;
|
||||
import org.apache.http.protocol.RequestUserAgent;
|
||||
import org.apache.http.util.VersionInfo;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link org.apache.http.client.HttpClient} pre-configured
|
||||
|
@ -180,7 +181,8 @@ public class DefaultHttpClient extends AbstractHttpClient {
|
|||
HttpProtocolParams.setContentCharset(params, HTTP.DEF_CONTENT_CHARSET.name());
|
||||
HttpConnectionParams.setTcpNoDelay(params, true);
|
||||
HttpConnectionParams.setSocketBufferSize(params, 8192);
|
||||
HttpProtocolParams.setUserAgent(params, HttpClientBuilder.DEFAULT_USER_AGENT);
|
||||
HttpProtocolParams.setUserAgent(params, VersionInfo.getUserAgent("Apache-HttpClient",
|
||||
"org.apache.http.client", DefaultHttpClient.class));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,8 +35,8 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
|
@ -209,15 +209,6 @@ public class HttpClientBuilder {
|
|||
|
||||
private List<Closeable> closeables;
|
||||
|
||||
static final String DEFAULT_USER_AGENT;
|
||||
static {
|
||||
final VersionInfo vi = VersionInfo.loadVersionInfo
|
||||
("org.apache.http.client", HttpClientBuilder.class.getClassLoader());
|
||||
final String release = (vi != null) ?
|
||||
vi.getRelease() : VersionInfo.UNAVAILABLE;
|
||||
DEFAULT_USER_AGENT = "Apache-HttpClient/" + release + " (java 1.5)";
|
||||
}
|
||||
|
||||
public static HttpClientBuilder create() {
|
||||
return new HttpClientBuilder();
|
||||
}
|
||||
|
@ -864,7 +855,8 @@ public class HttpClientBuilder {
|
|||
userAgentCopy = System.getProperty("http.agent");
|
||||
}
|
||||
if (userAgentCopy == null) {
|
||||
userAgentCopy = DEFAULT_USER_AGENT;
|
||||
userAgentCopy = VersionInfo.getUserAgent("Apache-HttpClient",
|
||||
"org.apache.http.client", getClass());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue