Extract setup of default HttpParams into public static method
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1045232 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
618754b6a9
commit
3fc9bd963c
|
@ -193,7 +193,19 @@ public class DefaultHttpClient extends AbstractHttpClient {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the default set of HttpParams.
|
* Creates the default set of HttpParams by invoking {@link DefaultHttpClient#setDefaultHttpParams(HttpParams)}
|
||||||
|
*
|
||||||
|
* @return a new instance of {@link SyncBasicHttpParams} with the defaults applied to it.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected HttpParams createHttpParams() {
|
||||||
|
HttpParams params = new SyncBasicHttpParams();
|
||||||
|
setDefaultHttpParams(params);
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the default set of HttpParams in the provided parameter.
|
||||||
* These are:
|
* These are:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@link CoreProtocolPNames#PROTOCOL_VERSION}: 1.1</li>
|
* <li>{@link CoreProtocolPNames#PROTOCOL_VERSION}: 1.1</li>
|
||||||
|
@ -203,27 +215,19 @@ public class DefaultHttpClient extends AbstractHttpClient {
|
||||||
* <li>{@link CoreProtocolPNames#USER_AGENT}: Apache-HttpClient/<release> (java 1.5)</li>
|
* <li>{@link CoreProtocolPNames#USER_AGENT}: Apache-HttpClient/<release> (java 1.5)</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
@Override
|
public static void setDefaultHttpParams(HttpParams params) {
|
||||||
protected HttpParams createHttpParams() {
|
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
|
||||||
HttpParams params = new SyncBasicHttpParams();
|
HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
|
||||||
HttpProtocolParams.setVersion(params,
|
HttpConnectionParams.setTcpNoDelay(params, true);
|
||||||
HttpVersion.HTTP_1_1);
|
HttpConnectionParams.setSocketBufferSize(params, 8192);
|
||||||
HttpProtocolParams.setContentCharset(params,
|
|
||||||
HTTP.DEFAULT_CONTENT_CHARSET);
|
|
||||||
HttpConnectionParams.setTcpNoDelay(params,
|
|
||||||
true);
|
|
||||||
HttpConnectionParams.setSocketBufferSize(params,
|
|
||||||
8192);
|
|
||||||
|
|
||||||
// determine the release version from packaged version info
|
// determine the release version from packaged version info
|
||||||
final VersionInfo vi = VersionInfo.loadVersionInfo
|
final VersionInfo vi = VersionInfo.loadVersionInfo
|
||||||
("org.apache.http.client", getClass().getClassLoader());
|
("org.apache.http.client", DefaultHttpClient.class.getClassLoader());
|
||||||
final String release = (vi != null) ?
|
final String release = (vi != null) ?
|
||||||
vi.getRelease() : VersionInfo.UNAVAILABLE;
|
vi.getRelease() : VersionInfo.UNAVAILABLE;
|
||||||
HttpProtocolParams.setUserAgent(params,
|
HttpProtocolParams.setUserAgent(params,
|
||||||
"Apache-HttpClient/" + release + " (java 1.5)");
|
"Apache-HttpClient/" + release + " (java 1.5)");
|
||||||
|
|
||||||
return params;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue