Spring Framework HttpComponentsClientHttpRequestFactory - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework HttpComponentsClientHttpRequestFactory class.

This code example shows how to use the following methods:setConnectTimeout, setReadTimeout
@EBean 
public class MyRequestFactory extends HttpComponentsClientHttpRequestFactory {
 
	private static final int TIME_OUT = 30 * 1000;
 
	public MyRequestFactory() { 
		setConnectTimeout(TIME_OUT);
		setReadTimeout(TIME_OUT);
	} 
} 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setConnectTimeout, setReadTimeout
 
    private HttpComponentsClientHttpRequestFactory mRequestFactory;
 
    public RequestProcessor() { 
        restTemplate = new RestTemplateExt();
        mRequestFactory = new HttpComponentsClientHttpRequestFactory();
        mRequestFactory.setConnectTimeout(CONNECT_TIMEOUT);
        mRequestFactory.setReadTimeout(READ_TIMEOUT);
 
        restTemplate.setRequestFactory(mRequestFactory);
        restTemplate.getMessageConverters().add(
                new MappingJacksonHttpMessageConverter()); 
    } 
 
    public HttpComponentsClientHttpRequestFactory getRequestFactory(){
        return mRequestFactory;
    } 
 
    public void setUserAgent(String userAgent) {
        mRequestFactory.getHttpClient().getParams()
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getHttpClient
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:destroy
	} 
 
	@After 
	public void destoryClient() throws Exception {
		// 退出时关闭HttpClient4连接池中的连接 
		httpClientRequestFactory.destroy();
	} 
 
	/** 
	 * 演示使用原始的exchange()方法来设置Headers. 
	 * 演示xml格式数据. 
	 * 演示jdk connection. 
	 */ 
	@Test
	public void getUserAsXML() { 
		// 设置Http Basic参数 
		HttpHeaders requestHeaders = new HttpHeaders();
		requestHeaders.set(com.google.common.net.HttpHeaders.AUTHORIZATION, Servlets.encodeHttpBasic("admin", "admin"));
		System.out.println("Http header is" + requestHeaders);
		HttpEntity<?> requestEntity = new HttpEntity(requestHeaders);
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
	 
	private HttpEntity<?> requestEntity;
 
	@Before 
	public void setup() { 
		template = new RestTemplate(new HttpComponentsClientHttpRequestFactory());		
		MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
		params.add("param", "value");
		requestEntity = new HttpEntity<MultiValueMap<String, String>>(params, null);
	} 
	 
	@Test
	public void requestParamPut() { 
		String url = baseUrl + "requestParam";
		ResponseEntity<String> response = template.exchange(url, HttpMethod.PUT, requestEntity, String.class);
		assertEquals("param=value", response.getBody());
	} 
	 
	@Test
	public void requestParamPost() { 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getHttpClient
This code example shows how to use the following methods:getHttpClient
public class HttpConnectionUtils { 
 
    public static RestTemplate getRestTemplate(Context context) {
        HttpClient client = HttpConnectionUtils.getDumbSSLHttpClient();
        // HttpClient client = HttpConnectionUtils.getSSLHttpClient(); 
        HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(client);
        requestFactory.getHttpClient().getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 2000);
        requestFactory.getHttpClient().getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 2000);
 
        RestTemplate template = new RestTemplate();
 
        setSerializers(requestFactory, template);
 
        return template;
    } 
 
    /** 
     * Sets serializer if some class should be treat different then default in 
     * simplexml library. 
     *  
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 */ 
public class PreemptiveAuthHttpRequestFactory extends HttpComponentsClientHttpRequestFactory {
    private final HttpHost targetHost;
 
    public PreemptiveAuthHttpRequestFactory(final String host, final int port, final String scheme) {
        super(); 
        targetHost = new HttpHost(host, port, scheme);
    } 
 
    @SuppressWarnings("unused") 
    public PreemptiveAuthHttpRequestFactory(final String host, final int port, final String scheme, final ClientConnectionManager conman, final HttpParams params) {
        super(); 
        targetHost = new HttpHost(host, port, scheme);
    } 
 
    // API 
 
    public AuthScope getAuthScope() {
        return new AuthScope(targetHost.getHostName(), targetHost.getPort());
    } 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    private String password; 
 
    /** 
     * コンストラクタです。 
     */ 
    public ProxyClientHttpRequestFactory() {} 
 
    /** 
     * プロパティの設定が終了したあとにHttpClientのインスタンスを生成し、プロキシの設定を行います。 
     * {@inheritDoc} 
     */ 
    @Override 
    public void afterPropertiesSet() throws Exception { 
 
        Assert.notNull(proxyHost, "プロキシホスト(proxyHost)は必須です。"); 
        Assert.notNull(proxyPort, "プロキシポート番号(proxyPort)は必須です。"); 
 
        PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(); 
        connectionManager.setMaxTotal(maxTotal); 
        connectionManager.setDefaultMaxPerRoute(defaultMaxPerRoute); 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
	 * with {@link HttpComponentsClientHttpRequestFactory}. 
	 * 
	 * @param baseUri the base uri 
	 */ 
	public YarnContainerClusterTemplate(String baseUri) {
		this.restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory());
		this.baseUri = baseUri;
	} 
 
	/** 
	 * Constructs a {@link YarnContainerClusterTemplate} using a given {@link RestTemplate}. 
	 * 
	 * @param baseUri the base uri 
	 * @param restTemplate the rest template 
	 */ 
	public YarnContainerClusterTemplate(String baseUri, RestTemplate restTemplate) {
		this.restTemplate = restTemplate;
		this.baseUri = baseUri;
	} 
 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Spring Framework HttpComponentsClientHttpRequestFactory Methods: