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


Java ClientHttpRequestExecution.execute方法代码示例

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


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

示例1: intercept

import org.springframework.http.client.ClientHttpRequestExecution; //导入方法依赖的package包/类
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body,
    ClientHttpRequestExecution execution) throws IOException {

  if (omegaContext.globalTxId() != null) {
    request.getHeaders().add(GLOBAL_TX_ID_KEY, omegaContext.globalTxId());
    request.getHeaders().add(LOCAL_TX_ID_KEY, omegaContext.localTxId());

    LOG.debug("Added {} {} and {} {} to request header",
        GLOBAL_TX_ID_KEY,
        omegaContext.globalTxId(),
        LOCAL_TX_ID_KEY,
        omegaContext.localTxId());
  }
  return execution.execute(request, body);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-saga,代码行数:17,代码来源:TransactionClientHttpRequestInterceptor.java

示例2: intercept

import org.springframework.http.client.ClientHttpRequestExecution; //导入方法依赖的package包/类
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
	throws IOException
{
	if (log.isDebugEnabled())
	{
		log.debug(String.format("Request: %s %s %s", request.getMethod(), request.getURI(),
			new String(body, getCharset(request))));
	}
	
	ClientHttpResponse response = execution.execute(request, body);
	
	if (log.isDebugEnabled())
	{
		log.debug(String.format("Response: %s %s", response.getStatusCode().value(),
			copyToString(response.getBody(), getCharset(response))));
	}
	
	return response;
}
 
开发者ID:markhobson,项目名称:spring-rest-template-logger,代码行数:21,代码来源:LoggingInterceptor.java

示例3: intercept

import org.springframework.http.client.ClientHttpRequestExecution; //导入方法依赖的package包/类
@Override
public ClientHttpResponse intercept(final HttpRequest request, final byte[] body,
		final ClientHttpRequestExecution execution) throws IOException {

	final HttpHeaders requestHeaders = request.getHeaders();

	for (final Entry<String, String> entry : headers.entrySet()) {
		requestHeaders.add(entry.getKey(), entry.getValue());
	}

	return execution.execute(request, body);
}
 
开发者ID:JanLoebel,项目名称:uaa-service,代码行数:13,代码来源:HttpHeaderInterceptor.java

示例4: intercept

import org.springframework.http.client.ClientHttpRequestExecution; //导入方法依赖的package包/类
@Override
public ClientHttpResponse intercept(final HttpRequest request, final byte[] body,
                                    final ClientHttpRequestExecution execution) throws IOException {
    final HttpHeaders headers = request.getHeaders();
    ClientHttpResponse execute = execution.execute(request, body);

    if (execute.getStatusCode() == HttpStatus.UNAUTHORIZED) {
        List<String> list = execute.getHeaders().get("Www-Authenticate");
        if (!CollectionUtils.isEmpty(list)) {
            String tokenString = list.get(0);
            RegistryAuthAdapter.AuthContext ctx = new RegistryAuthAdapter.AuthContext(headers,
              HttpHeaders.readOnlyHttpHeaders(headers),
              tokenString);
            adapter.handle(ctx);
            return execution.execute(request, body);
        }
    }
    return execute;
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:20,代码来源:RegistryAuthInterceptor.java

示例5: intercept

import org.springframework.http.client.ClientHttpRequestExecution; //导入方法依赖的package包/类
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException
{
   long startTime = System.currentTimeMillis();

   ClientHttpResponse response = execution.execute(request, body);

   long endTime = System.currentTimeMillis();

   if(useDebug)
   {
      LOG.debug("Request for {} took {} ms", request.getURI().toString(), endTime - startTime);
   }
   else
   {
      LOG.info("Request for {} took {} ms", request.getURI().toString(), endTime - startTime);
   }

   return response;
}
 
开发者ID:HomeAdvisor,项目名称:Robusto,代码行数:21,代码来源:ResponseTimeInterceptor.java

示例6: intercept

import org.springframework.http.client.ClientHttpRequestExecution; //导入方法依赖的package包/类
/**
 * This isn't needed now - but was needed when trying to figure out why term extractor wasn't
 * returning data.
 */
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
        throws IOException {

    // HttpHeaders headers = request.getHeaders();
    // headers.add("Accept",
    // "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
    /*
     * headers.add("X-User-Agent",
     * "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 Query String Parametersview sourceview URL encoded"
     * );
     * headers.add("Accept-Encoding", "gzip, deflate, sdch");
     * headers.add("Accept-Language", "en-US,en;q=0.8");
     * headers.add("Cache-Control", "max-age=0");
     * headers.add("Connection", "keep-alive");
     * headers.add("Cookie",
     * "CTK=19asr9k230nph1f0; RF=\"TFTzyBUJoNr4wP5QpciSOn6ifEMTEVq4ARC0hGY5P-gkhvCY-D1UltWIqfxDhxhHqiN1UggLuPE=\"; IRF=\"1qRi-3v0F_uf-yOkOwHemehIPriDHeZ-AD_rnIAayJ8=\"; CSRF=RCTCj8Abxq9j3u0bL2cYybndr26rFwzL; LC=\"co=FR&hl=fr_FR\"; SHOE=\"uQsQNsQkFYUJ008ISZ8DRWVFtv6W_JMN4mdL-LLfXiJuOW0VoJAjjiVpkv4kQoV23Sg-_-1ytM1OqAz8ROZROJDcOAoDohJHdMU_EBqxbwMOyVIOjrryq7DH189GzMI=\"; PUB=1; BIGipServerjob_iad=!YlkJJm1KgDuhYWHnj+SL47ecq6aoxVInDdjtEnHOjpnVpzOxZBWTrFttjRp0eryuGzkmkx1TYdWHS2k=; INDEED_CSRF_TOKEN=ClPCTHOQ2zlw3egLg2bQl8WakmtEeWpf; _mkto_trk=id:699-SXJ-715&token:_mch-indeed.com-1420554563497-42566; TS01c598d3=0160a2beff09f16a3c10d0f0f0a6a553318c160463ca6c315ab349cad0aefb8dfaa95db17be5052c844f60ecad51ec7c72d952d440688e76cfdabdb3074ee99a7773918ac93d8b06d43de5f602f27582982fb39fbe34263631f197d1f19e0fb70752db8b562fd68ecd5716b3e3d26da06ac246cd6f060c5f347cb466bd53402f81a2506ff7ee638943466c4de4e47bb62d5ee23bd42ae6ba9a59c0ca38e446b40736cbc688; DCT=4; JSESSIONID=97208F039EED60B31A14EF12640B8D84.jasxB_iad-job18; TS016080f8=0160a2beff8af91efc651c51dff589379d71c19e188469c827f0265638b0194c2885f98c9fe455fc17b6ea59258cb631c44485df3e271eae4c2090e2cedce12f163b39094c07e6f01fc7144638866b7333691120a4c4648f7b3b8f00c08419b665958f61ce"
     * );
     * headers.add("DNT", "1");
     * headers.add("Host", "api.indeed.com");
     */
    return execution.execute(request, body);
}
 
开发者ID:jhaood,项目名称:github-job-keywords,代码行数:28,代码来源:XUserAgentInterceptor.java

示例7: intercept

import org.springframework.http.client.ClientHttpRequestExecution; //导入方法依赖的package包/类
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
		throws IOException {
	String urlTemplate = RestTemplateUrlTemplateHolder.getRestTemplateUrlTemplate();
	if (urlTemplate == null)
		urlTemplate = "none";

	long startTime = registry.clock().wallTime();
	String status = "CLIENT_ERROR";
	try {
		ClientHttpResponse response = execution.execute(request, body);
		status = ((Integer) response.getRawStatusCode()).toString();
		return response;
	} finally {
		String host = request.getURI().getHost();

		registry.timer(metricName, "method", request.getMethod().name(), "uri",
				urlTemplate.replaceAll("^https?://[^/]+/", "").replaceAll("/", "_").replaceAll("[{}]", "-"),
				"status", status, "clientName", host != null ? host : "none").record(
				registry.clock().wallTime() - startTime, TimeUnit.MILLISECONDS);
	}
}
 
开发者ID:netflix-spring-one,项目名称:spring-cloud-netflix-contrib,代码行数:23,代码来源:SpectatorClientHttpRequestInterceptor.java

示例8: createRequest

import org.springframework.http.client.ClientHttpRequestExecution; //导入方法依赖的package包/类
public LoadBalancerRequest<ClientHttpResponse> createRequest(final HttpRequest request,
		final byte[] body, final ClientHttpRequestExecution execution) {
	return new LoadBalancerRequest<ClientHttpResponse>() {

		@Override
		public ClientHttpResponse apply(final ServiceInstance instance)
				throws Exception {
			HttpRequest serviceRequest = new ServiceRequestWrapper(request, instance, loadBalancer);
			if (transformers != null) {
				for (LoadBalancerRequestTransformer transformer : transformers) {
					serviceRequest = transformer.transformRequest(serviceRequest, instance);
				}
			}
			return execution.execute(serviceRequest, body);
		}

	};
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:19,代码来源:LoadBalancerRequestFactory.java

示例9: intercept

import org.springframework.http.client.ClientHttpRequestExecution; //导入方法依赖的package包/类
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
	logger.info("Sending headers: " + request.getHeaders());
	
	if (body.length > 0) {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		
		HexDump.dump(body, 0, baos, 0);
		
		logger.info("Sending to [{}]: \n{}", request.getURI(), baos.toString(Charsets.UTF_8.name()).trim());
	} else {
		logger.info("Sending empty body to [{}]!", request.getURI());
	}
	
	return execution.execute(request, body);
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:17,代码来源:HttpTransportTest.java

示例10: intercept

import org.springframework.http.client.ClientHttpRequestExecution; //导入方法依赖的package包/类
public ClientHttpResponse intercept(final HttpRequest request, final byte[] body,
									ClientHttpRequestExecution execution) throws
																		  IOException {
	HttpRequest protectedResourceRequest = new HttpRequestDecorator(request) {
		@Override
		public URI getURI() {

			String ts = Long.toString(TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()));
			String hash = DigestUtils.sha1Hex(sharedSecret + ts).toLowerCase();

			UriComponentsBuilder builder = UriComponentsBuilder.fromUri(super.getURI());
			builder.queryParam("api_key", apiKey);
			builder.queryParam("ts", ts);
			builder.queryParam("hash", hash);

			// all params are already encoded at this point
			UriComponents uriComponents = builder.build(true);
			logger.debug("requesting SlideShare API: " + uriComponents.toUriString());

			return uriComponents.toUri();
		}
	};

	return execution.execute(protectedResourceRequest, body);
}
 
开发者ID:ttddyy,项目名称:spring-social-slideshare,代码行数:26,代码来源:SlideShareTemplate.java

示例11: intercept

import org.springframework.http.client.ClientHttpRequestExecution; //导入方法依赖的package包/类
@Override
public ClientHttpResponse intercept(final HttpRequest request, final byte[] body,
        final ClientHttpRequestExecution execution) throws IOException {
    HttpHeaders headers = request.getHeaders();
    headers.add("X-Auth-Token", tokenManager.getTokenHolder().getUnscoped());
    if (LOG.isInfoEnabled()) {
        LOG.info("X-Auth-Token: " + tokenManager.getTokenHolder().getUnscoped());
    }
    return execution.execute(request, body);
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:11,代码来源:UnscopedClientHttpRequestInterceptor.java

示例12: intercept

import org.springframework.http.client.ClientHttpRequestExecution; //导入方法依赖的package包/类
@Override
public ClientHttpResponse intercept(final HttpRequest request, final byte[] body,
        final ClientHttpRequestExecution execution) throws IOException {
    HttpHeaders headers = request.getHeaders();
    headers.add("X-Auth-Token", tokenManager.getTokenHolder().getScopedToken(projectId));
    if (LOG.isInfoEnabled()) {
        LOG.info("X-Auth-Token: " + tokenManager.getTokenHolder().getScopedToken(projectId));
    }
    return execution.execute(request, body);
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:11,代码来源:ScopedClientHttpRequestInterceptor.java

示例13: intercept

import org.springframework.http.client.ClientHttpRequestExecution; //导入方法依赖的package包/类
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
    logRequest(request, body);
    ClientHttpResponse response = execution.execute(request, body);
    logResponse(response);
    return response;
}
 
开发者ID:jopache,项目名称:Settings,代码行数:8,代码来源:ApiClient.java

示例14: intercept

import org.springframework.http.client.ClientHttpRequestExecution; //导入方法依赖的package包/类
@Override
public ClientHttpResponse intercept(final HttpRequest httpRequest, final byte[] bytes,
                                    final ClientHttpRequestExecution clientHttpRequestExecution) throws IOException
{
    LOG.debug("################################ LoggingRequestInterceptor Start #################################");
    traceRequest(httpRequest, bytes);
    ClientHttpResponse response = clientHttpRequestExecution.execute(httpRequest, bytes);
    traceResponse(response);
    LOG.debug("################################ LoggingRequestInterceptor End ###################################");
    return response;
}
 
开发者ID:wenhao,项目名称:ci-hands-on,代码行数:12,代码来源:LoggingRequestInterceptor.java

示例15: intercept

import org.springframework.http.client.ClientHttpRequestExecution; //导入方法依赖的package包/类
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
        throws IOException {
    HttpHeaders headers = request.getHeaders();
    headers.add(AUTHORIZATION_HEADER, gitHubToken);
    headers.add(USER_AGENT_HEADER, USER_AGENT_VALUE);
    headers.setContentType(MediaType.APPLICATION_JSON);
    return execution.execute(request, body);
}
 
开发者ID:redhat-developer,项目名称:che-starter,代码行数:10,代码来源:GitHubInterceptor.java


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