Package org.springframework.http.client

Examples of org.springframework.http.client.ClientHttpRequestInterceptor


  @Test
  @OAuth2ContextConfiguration(resource = AutoApproveImplicit.class, initialize = false)
  public void testPostForAutomaticApprovalToken() throws Exception {
    final ImplicitAccessTokenProvider implicitProvider = new ImplicitAccessTokenProvider();
    implicitProvider.setInterceptors(Arrays
        .<ClientHttpRequestInterceptor> asList(new ClientHttpRequestInterceptor() {
          public ClientHttpResponse intercept(HttpRequest request, byte[] body,
              ClientHttpRequestExecution execution) throws IOException {
            ClientHttpResponse result = execution.execute(request, body);
            latestHeaders = result.getHeaders();
            return result;
View Full Code Here


    //private PaymillContext paymentContext;

    @PostConstruct
    public void init() {
        jsonMapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
        template.getInterceptors().add(new ClientHttpRequestInterceptor() {

            @Override
            public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
                    throws IOException {
                request.getHeaders().add("Accept", "application/json");
View Full Code Here

    httpClientRequestFactory.setConnectTimeout(20000);

    httpClientRestTemplate.setRequestFactory(httpClientRequestFactory);

    // 设置处理HttpBasic Header的Interceptor
    ClientHttpRequestInterceptor interceptor = new HttpBasicInterceptor("admin", "admin");
    httpClientRestTemplate.setInterceptors(Lists.newArrayList(interceptor));
  }
View Full Code Here

    return converter;
  }

  private RestTemplate createRestTemplate(String accessToken, OAuth2Version version, TokenStrategy tokenStrategy) {
    RestTemplate client = createRestTemplateWithCulledMessageConverters();
    ClientHttpRequestInterceptor interceptor = tokenStrategy.interceptor(accessToken, version);
    List<ClientHttpRequestInterceptor> interceptors = new LinkedList<ClientHttpRequestInterceptor>();
    interceptors.add(interceptor);
    client.setInterceptors(interceptors);
    return client;
  }
View Full Code Here

    rest.setMessageConverters(messageConverters);

    //Add rate limit logging
    if (LOG_GITHUB_RATE_LIMIT) {
          rest.getInterceptors().add(new ClientHttpRequestInterceptor() {

        //@Override
        public ClientHttpResponse intercept(HttpRequest request,
            byte[] body, ClientHttpRequestExecution execution)
            throws IOException {
View Full Code Here

  }

  @Override
  public RestTemplate apply(RestTemplate rest) {
    List<ClientHttpRequestInterceptor> interceptors = rest.getInterceptors();
    interceptors.add(new ClientHttpRequestInterceptor() {
      public ClientHttpResponse intercept(HttpRequest request, byte[] body,
          ClientHttpRequestExecution execution) throws IOException {
        if (matchHost(request.getURI().getHost())) {
          HttpHeaders headers = request.getHeaders();
          if (!headers.containsKey("Authorization")) {
View Full Code Here

TOP

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

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.