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


Java BufferingClientHttpRequestFactory类代码示例

本文整理汇总了Java中org.springframework.http.client.BufferingClientHttpRequestFactory的典型用法代码示例。如果您正苦于以下问题:Java BufferingClientHttpRequestFactory类的具体用法?Java BufferingClientHttpRequestFactory怎么用?Java BufferingClientHttpRequestFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getTemplate

import org.springframework.http.client.BufferingClientHttpRequestFactory; //导入依赖的package包/类
public static RestTemplate getTemplate(ClientHttpRequestInterceptor interceptor) {
    RestTemplate restTemplate = new RestTemplate();

    List<ClientHttpRequestInterceptor> ris = new ArrayList<>();
    ris.add(interceptor);
    restTemplate.setInterceptors(ris);
    SimpleClientHttpRequestFactory httpFactory = new SimpleClientHttpRequestFactory();
    httpFactory.setOutputStreaming(false);
    restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(httpFactory));
    restTemplate.getMessageConverters().add(0, new StringHttpMessageConverter(Charset.forName("UTF-8")));
    return restTemplate;
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:13,代码来源:TemplateUtil.java

示例2: AbstractIT

import org.springframework.http.client.BufferingClientHttpRequestFactory; //导入依赖的package包/类
protected AbstractIT() {
	clientFactory = Configuration.builder()
			.setBaseUri(System.getProperty("baseUrl"))
			.setClientHttpRequestFactory(new BufferingClientHttpRequestFactory(
					new HttpComponentsClientHttpRequestFactory()))
			.setRestTemplateConfigurer(new RestTemplateConfigurer() {
				
				@Override
				public void configure(RestTemplate restTemplate) {
					restTemplate.getInterceptors().addAll(asList(
						new LoggingClientHttpRequestInterceptor(),
						createdEntityRecordingInterceptor
					));
				}
			})
			.build()
			.buildClientFactory();
}
 
开发者ID:BlackPepperSoftware,项目名称:bowman,代码行数:19,代码来源:AbstractIT.java

示例3: createHttpFactory

import org.springframework.http.client.BufferingClientHttpRequestFactory; //导入依赖的package包/类
/**
 * Extension point for plugging in different HTTP factories.
 * @return Default is a {@link BufferingClientHttpRequestFactory}
 */
protected ClientHttpRequestFactory createHttpFactory(
      int connectTimeout,
      int requestTimeout)
{
   SimpleClientHttpRequestFactory scrf = new SimpleClientHttpRequestFactory();
   scrf.setConnectTimeout(connectTimeout);
   scrf.setReadTimeout(requestTimeout);

   //
   // Wrap the default request factory in a BufferingClientHttpRequestFactory
   // which allows us to read response bodies multiple times. This is needed
   // because some interceptors will need to consume the body before the final
   // response gets to the caller.
   //

   return new BufferingClientHttpRequestFactory(scrf);
}
 
开发者ID:HomeAdvisor,项目名称:Robusto,代码行数:22,代码来源:SpringRestClient.java

示例4: disableSSL

import org.springframework.http.client.BufferingClientHttpRequestFactory; //导入依赖的package包/类
public static void disableSSL(RestTemplate restTemplate) {
    try {
        SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom()
            .loadTrustMaterial(null, (X509Certificate[] chain, String authType) -> true)
            .build();
        CloseableHttpClient httpClient = HttpClients.custom()
            .setSSLSocketFactory(new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE))
            .build();
        HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
        requestFactory.setHttpClient(httpClient);
        restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(requestFactory));
    } catch (Exception e) {
        log.error("Exception occurred while creating http factory, error={}", e.getMessage(), e);
    }
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:16,代码来源:TemplateUtil.java

示例5: buildRestTemplate

import org.springframework.http.client.BufferingClientHttpRequestFactory; //导入依赖的package包/类
/**
 * Build the RestTemplate used to make HTTP requests.
 * @return RestTemplate
 */
protected RestTemplate buildRestTemplate() {
    RestTemplate restTemplate = new RestTemplate();
    // This allows us to read the response more than once - Necessary for debugging.
    restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(restTemplate.getRequestFactory()));
    return restTemplate;
}
 
开发者ID:jopache,项目名称:Settings,代码行数:11,代码来源:ApiClient.java

示例6: interceptorToRequestFactory

import org.springframework.http.client.BufferingClientHttpRequestFactory; //导入依赖的package包/类
private static LoggingRequestFactory interceptorToRequestFactory(LoggingRequestInterceptor lri) {
    List<ClientHttpRequestInterceptor> lInterceptors = new ArrayList<>();
    lInterceptors.add(lri);
    SimpleClientHttpRequestFactory chrf = new SimpleClientHttpRequestFactory();
    chrf.setOutputStreaming(false);
    return new LoggingRequestFactory(
            new BufferingClientHttpRequestFactory(chrf),
            lInterceptors
    );
}
 
开发者ID:zg2pro,项目名称:spring-rest-basis,代码行数:11,代码来源:LoggingRequestFactoryFactory.java

示例7: interceptorsIntegration

import org.springframework.http.client.BufferingClientHttpRequestFactory; //导入依赖的package包/类
@Override
protected void interceptorsIntegration(List<ClientHttpRequestInterceptor> lInterceptors, Object sslConfiguration) {
    this.setInterceptors(lInterceptors);
    SimpleClientHttpRequestFactory chrf = new SimpleClientHttpRequestFactory();
    chrf.setOutputStreaming(false);
    this.setRequestFactory(
            new InterceptingClientHttpRequestFactory(
                    new BufferingClientHttpRequestFactory(chrf),
                    lInterceptors
            )
    );
}
 
开发者ID:zg2pro,项目名称:spring-rest-basis,代码行数:13,代码来源:Zg2proRestTemplate.java

示例8: testInterceptor

import org.springframework.http.client.BufferingClientHttpRequestFactory; //导入依赖的package包/类
/**
 * hard to check the logs provided by the interceptor when there's no error
 * however this unit test garantees the interceptor does not alter the reply
 * from the rest service.
 */
@Test
public void testInterceptor() {
    List<ClientHttpRequestInterceptor> lInterceptors = new ArrayList<>();
    //spring boot default log level is info
    lInterceptors.add(new LoggingRequestInterceptor(StandardCharsets.ISO_8859_1, 100, Level.ERROR));
    SimpleClientHttpRequestFactory chrf = new SimpleClientHttpRequestFactory();
    chrf.setOutputStreaming(false);
    rt.getRestTemplate().setRequestFactory(new InterceptingClientHttpRequestFactory(
            new BufferingClientHttpRequestFactory(chrf),
            lInterceptors
    ));
    ResponseEntity<String> resp = rt.getForEntity(MockedControllers.TEST_URL_GET, String.class);
    assertThat(resp.getBody()).isEqualTo(MockedControllers.TEST_RETURN_VALUE);
}
 
开发者ID:zg2pro,项目名称:spring-rest-basis,代码行数:20,代码来源:LogsTest.java

示例9: normalTemplate

import org.springframework.http.client.BufferingClientHttpRequestFactory; //导入依赖的package包/类
@Bean
public RestTemplate normalTemplate() {
    List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>();
    interceptors.add(new ClientApiKeyHeaderInterceptor());
    interceptors.add(new ClientLogInterceptor());

    // Out-going serialization
    RestTemplate restTemplate = new RestTemplate(Collections.singletonList(getMessageConverter()));
    restTemplate.setInterceptors(interceptors);
    restTemplate.setRequestFactory(
            new BufferingClientHttpRequestFactory(
                    new HttpComponentsClientHttpRequestFactory()));

    return restTemplate;
}
 
开发者ID:RWTH-i5-IDSG,项目名称:steve-plugsurfing,代码行数:16,代码来源:PlugSurfingConfiguration.java

示例10: connectTimeoutCanBeConfiguredOnAWrappedRequestFactory

import org.springframework.http.client.BufferingClientHttpRequestFactory; //导入依赖的package包/类
@Test
public void connectTimeoutCanBeConfiguredOnAWrappedRequestFactory() {
	SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
	this.builder.requestFactory(new BufferingClientHttpRequestFactory(requestFactory))
			.setConnectTimeout(1234).build();
	assertThat(ReflectionTestUtils.getField(requestFactory, "connectTimeout"))
			.isEqualTo(1234);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:RestTemplateBuilderTests.java

示例11: readTimeoutCanBeConfiguredOnAWrappedRequestFactory

import org.springframework.http.client.BufferingClientHttpRequestFactory; //导入依赖的package包/类
@Test
public void readTimeoutCanBeConfiguredOnAWrappedRequestFactory() {
	SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
	this.builder.requestFactory(new BufferingClientHttpRequestFactory(requestFactory))
			.setReadTimeout(1234).build();
	assertThat(ReflectionTestUtils.getField(requestFactory, "readTimeout"))
			.isEqualTo(1234);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:RestTemplateBuilderTests.java

示例12: setUp

import org.springframework.http.client.BufferingClientHttpRequestFactory; //导入依赖的package包/类
@Before
public void setUp() {
	SlideShareTemplate slideShareTemplate = new SlideShareTemplate("key", "secret");
	RestTemplate restTemplate = slideShareTemplate.getRestTemplate();
	mockServer = MockRestServiceServer.createServer(restTemplate);

	// creating mockServer replaces RequestFactory in restTemplate to RequestMatcherClientHttpRequestFactory.
	// in order to support multiple reads in test, re-wrap the mock requestFactory and set to restTemplate.
	restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(restTemplate.getRequestFactory()));
	slideshowOperations = slideShareTemplate.slideshowOperations();
}
 
开发者ID:ttddyy,项目名称:spring-social-slideshare,代码行数:12,代码来源:AbstractSlideshareTemplateTest.java

示例13: RamlRestTemplate

import org.springframework.http.client.BufferingClientHttpRequestFactory; //导入依赖的package包/类
private RamlRestTemplate(RamlChecker ramlChecker, boolean notSending, ReportStore reportStore, ClientHttpRequestFactory requestFactory) {
    this.ramlChecker = ramlChecker;
    this.notSending = notSending;
    this.reportStore = reportStore;
    this.originalRequestFactory = requestFactory;
    final RamlRequestInterceptor interceptor = new RamlRequestInterceptor(ramlChecker, notSending, reportStore);
    setRequestFactory(new InterceptingClientHttpRequestFactory(
            new BufferingClientHttpRequestFactory(requestFactory), Collections.<ClientHttpRequestInterceptor>singletonList(interceptor)));
}
 
开发者ID:nidi3,项目名称:raml-tester,代码行数:10,代码来源:RamlRestTemplate.java

示例14: customize

import org.springframework.http.client.BufferingClientHttpRequestFactory; //导入依赖的package包/类
@Override
public void customize(RestTemplate restTemplate)
{
	restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(restTemplate.getRequestFactory()));
	restTemplate.getInterceptors().add(new LoggingInterceptor(log));
}
 
开发者ID:markhobson,项目名称:spring-rest-template-logger,代码行数:7,代码来源:LoggingCustomizer.java


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