本文整理匯總了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());
}