当前位置: 首页>>代码示例>>Java>>正文


Java RequestConfig.DEFAULT属性代码示例

本文整理汇总了Java中org.apache.http.client.config.RequestConfig.DEFAULT属性的典型用法代码示例。如果您正苦于以下问题:Java RequestConfig.DEFAULT属性的具体用法?Java RequestConfig.DEFAULT怎么用?Java RequestConfig.DEFAULT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.http.client.config.RequestConfig的用法示例。


在下文中一共展示了RequestConfig.DEFAULT属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createAsyncRequest

@Override
public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod) throws IOException {
	HttpAsyncClient asyncClient = getHttpAsyncClient();
	startAsyncClient();
	HttpUriRequest httpRequest = createHttpUriRequest(httpMethod, uri);
	postProcessHttpRequest(httpRequest);
       HttpContext context = createHttpContext(httpMethod, uri);
       if (context == null) {
           context = HttpClientContext.create();
       }
       // Request configuration not set in the context
       if (context.getAttribute(HttpClientContext.REQUEST_CONFIG) == null) {
           // Use request configuration given by the user, when available
           RequestConfig config = null;
           if (httpRequest instanceof Configurable) {
               config = ((Configurable) httpRequest).getConfig();
           }
           if (config == null) {
               config = RequestConfig.DEFAULT;
           }
           context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
       }
	return new HttpComponentsAsyncClientHttpRequest(asyncClient, httpRequest, context);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:HttpComponentsAsyncClientHttpRequestFactory.java

示例2: createRequest

@Override
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
	CloseableHttpClient client = (CloseableHttpClient) getHttpClient();
	Assert.state(client != null, "Synchronous execution requires an HttpClient to be set");
	HttpUriRequest httpRequest = createHttpUriRequest(httpMethod, uri);
	postProcessHttpRequest(httpRequest);
       HttpContext context = createHttpContext(httpMethod, uri);
       if (context == null) {
           context = HttpClientContext.create();
       }
       // Request configuration not set in the context
       if (context.getAttribute(HttpClientContext.REQUEST_CONFIG) == null) {
           // Use request configuration given by the user, when available
           RequestConfig config = null;
           if (httpRequest instanceof Configurable) {
               config = ((Configurable) httpRequest).getConfig();
           }
           if (config == null) {
               if (this.socketTimeout > 0 || this.connectTimeout > 0) {
                   config = RequestConfig.custom()
                           .setConnectTimeout(this.connectTimeout)
                           .setSocketTimeout(this.socketTimeout)
                           .build();
               }
			else {
                   config = RequestConfig.DEFAULT;
               }
           }
           context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
       }
	if (this.bufferRequestBody) {
		return new HttpComponentsClientHttpRequest(client, httpRequest, context);
	}
	else {
		return new HttpComponentsStreamingClientHttpRequest(client, httpRequest, context);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:HttpComponentsClientHttpRequestFactory.java


注:本文中的org.apache.http.client.config.RequestConfig.DEFAULT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。