本文整理汇总了Java中org.apache.commons.httpclient.params.HttpMethodParams.setSoTimeout方法的典型用法代码示例。如果您正苦于以下问题:Java HttpMethodParams.setSoTimeout方法的具体用法?Java HttpMethodParams.setSoTimeout怎么用?Java HttpMethodParams.setSoTimeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.httpclient.params.HttpMethodParams
的用法示例。
在下文中一共展示了HttpMethodParams.setSoTimeout方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fastFailPing
import org.apache.commons.httpclient.params.HttpMethodParams; //导入方法依赖的package包/类
/**
* @return the http response code returned from the server. Response code 200 means success.
*/
public static int fastFailPing(AuthenticatedUrl url) throws IOException
{
PingRequest pingRequest = null;
try
{
HttpClient httpClient = getHttpClient(url);
pingRequest = new PingRequest(url.getPath());
HttpMethodParams params = pingRequest.getParams();
params.setSoTimeout(PING_TIMEOUT);
httpClient.executeMethod(pingRequest);
return pingRequest.getStatusCode();
}
finally
{
if (pingRequest != null)
{
pingRequest.releaseConnection();
}
}
}
示例2: requestNewSession
import org.apache.commons.httpclient.params.HttpMethodParams; //导入方法依赖的package包/类
public static Cookie[] requestNewSession(AuthenticatedUrl url)
{
CreateSessionRequest createSessionRequest = null;
try
{
HttpClient httpClient = getHttpClient(url);
createSessionRequest = new CreateSessionRequest(url.getPath());
HttpMethodParams params = createSessionRequest.getParams();
params.setSoTimeout(PING_TIMEOUT);
httpClient.executeMethod(createSessionRequest);
return httpClient.getState().getCookies();
}
catch (Exception e)
{
throw new RuntimeException("Failed to create session", e);
}
finally
{
if (createSessionRequest != null)
{
createSessionRequest.releaseConnection();
}
}
}
示例3: configureHttpMethod
import org.apache.commons.httpclient.params.HttpMethodParams; //导入方法依赖的package包/类
private void configureHttpMethod(boolean skipContentCache, CacheData cacheData, long onceTimeOut,
HttpMethod httpMethod) {
if (skipContentCache && null != cacheData) {
if (null != cacheData.getLastModifiedHeader() && Constants.NULL != cacheData.getLastModifiedHeader()) {
httpMethod.addRequestHeader(Constants.IF_MODIFIED_SINCE, cacheData.getLastModifiedHeader());
}
if (null != cacheData.getMd5() && Constants.NULL != cacheData.getMd5()) {
httpMethod.addRequestHeader(Constants.CONTENT_MD5, cacheData.getMd5());
}
}
httpMethod.addRequestHeader(Constants.ACCEPT_ENCODING, "gzip,deflate");
// 设置HttpMethod的参数
HttpMethodParams params = new HttpMethodParams();
params.setSoTimeout((int) onceTimeOut);
// ///////////////////////
httpMethod.setParams(params);
httpClient.getHostConfiguration().setHost(diamondConfigure.getDomainNameList().get(this.domainNamePos.get()),
diamondConfigure.getPort());
}
示例4: configureAckHttpMethod
import org.apache.commons.httpclient.params.HttpMethodParams; //导入方法依赖的package包/类
private void configureAckHttpMethod(HttpMethod httpMethod, long onceTimeOut) {
// ����appName�Ϳͻ��˰汾
if (null != this.appName) {
httpMethod.addRequestHeader(Constants.APPNAME, this.appName);
}
httpMethod.addRequestHeader(Constants.CLIENT_VERSION_HEADER,
Constants.CLIENT_VERSION);
// ����HttpMethod�IJ���
HttpMethodParams params = new HttpMethodParams();
params.setSoTimeout((int) onceTimeOut);
httpMethod.setParams(params);
httpClient.getHostConfiguration().setHost(
diamondConfigure.getDomainNameList().get(
this.domainNamePos.get()), diamondConfigure.getPort());
}
示例5: configureHttpMethod
import org.apache.commons.httpclient.params.HttpMethodParams; //导入方法依赖的package包/类
private void configureHttpMethod(boolean skipContentCache,
CacheData cacheData, long onceTimeOut, HttpMethod httpMethod) {
if (skipContentCache && null != cacheData) {
if (null != cacheData.getLastModifiedHeader()
&& Constants.NULL != cacheData.getLastModifiedHeader()) {
httpMethod.addRequestHeader(Constants.IF_MODIFIED_SINCE,
cacheData.getLastModifiedHeader());
}
if (null != cacheData.getMd5()
&& Constants.NULL != cacheData.getMd5()) {
httpMethod.addRequestHeader(Constants.CONTENT_MD5,
cacheData.getMd5());
}
}
// ����appName�Ϳͻ��˰汾
if (null != this.appName) {
httpMethod.addRequestHeader(Constants.APPNAME, this.appName);
}
httpMethod.addRequestHeader(Constants.CLIENT_VERSION_HEADER,
Constants.CLIENT_VERSION);
httpMethod.addRequestHeader(Constants.ACCEPT_ENCODING, "gzip,deflate");
// ����HttpMethod�IJ���
HttpMethodParams params = new HttpMethodParams();
params.setSoTimeout((int) onceTimeOut);
// ///////////////////////
httpMethod.setParams(params);
httpClient.getHostConfiguration().setHost(
diamondConfigure.getDomainNameList().get(
this.domainNamePos.get()), diamondConfigure.getPort());
}