Package org.springframework.http.client

Examples of org.springframework.http.client.HttpComponentsClientHttpRequestFactory


    return restTemplate;
  }

  public ClientHttpRequestFactory createRequestFactory(HttpProxyConfiguration httpProxyConfiguration, boolean trustSelfSignedCerts) {
    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
    DefaultHttpClient httpClient = (DefaultHttpClient) requestFactory.getHttpClient();

    if (trustSelfSignedCerts) {
      registerSslSocketFactory(httpClient);
    }
   
View Full Code Here


    return client;
  }

  public RestOperations createRestTemplate() {
    RestTemplate client = new RestTemplate();
    client.setRequestFactory(new HttpComponentsClientHttpRequestFactory() {
      @Override
      protected HttpContext createHttpContext(HttpMethod httpMethod, URI uri) {
        HttpClientContext context = HttpClientContext.create();
        Builder builder = RequestConfig.custom().setCookieSpec(CookieSpecs.IGNORE_COOKIES)
            .setAuthenticationEnabled(false).setRedirectsEnabled(false);
View Full Code Here

 
  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);
  }
View Full Code Here

        return null;
    }

    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate(new HttpComponentsClientHttpRequestFactory(HttpClientBuilder.create().build()));
    }
View Full Code Here

  // With Apache HttpComponents HttpClient 4.1.3 (i.e. lower than 4.2) on the classpath,
  // use of HTTP PATCH should result in exception with helpful message.

  @Test
  public void test() {
    RestTemplate restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory());
    try {
      restTemplate.exchange("/someUrl", HttpMethod.PATCH, null, null);
      fail("Expected exception");
    }
    catch (IllegalArgumentException ex) {
View Full Code Here

  private RestTemplate template;

  @Before
  public void createTemplate() {
    template = new RestTemplate(new HttpComponentsClientHttpRequestFactory());
  }
View Full Code Here

  private static PartListServlet partListServlet;


  @Before
  public void createTemplate() {
    template = new RestTemplate(new HttpComponentsClientHttpRequestFactory());
  }
View Full Code Here

  public void setUp() {
    AllEncompassingFormHttpMessageConverter converter = new AllEncompassingFormHttpMessageConverter();
    converter.setPartConverters(Arrays.<HttpMessageConverter<?>>asList(
        new ResourceHttpMessageConverter(), new MappingJackson2HttpMessageConverter()));

    restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory());
    restTemplate.setMessageConverters(Arrays.<HttpMessageConverter<?>>asList(converter));
  }
View Full Code Here

     * Construct the client factory bean with user credentials.
     */
    public HttpComponentsClientHttpRequestFactory getObject() throws Exception {
        Assert.notNull(credentials, "User credentials not set properly!");
       
        HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient) {
            @Override
            protected HttpContext createHttpContext(HttpMethod httpMethod, URI uri) {
                // we have to use preemptive authentication
                // therefore add some basic auth cache to the local context
                AuthCache authCache = new BasicAuthCache();
View Full Code Here

            new TrustSelfSignedStrategy()).build());

    HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
        .build();

    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
    restTemplate = new RestTemplate(requestFactory);
  }
View Full Code Here

TOP

Related Classes of org.springframework.http.client.HttpComponentsClientHttpRequestFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.