org.springframework.http.client.AbstractClientHttpRequest Java Examples

The following examples show how to use org.springframework.http.client.AbstractClientHttpRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestRequestInterceptor.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
    Object ret) throws Throwable {
    ClientHttpRequest clientHttpRequest = (ClientHttpRequest) ret;
    if (clientHttpRequest instanceof AbstractClientHttpRequest) {
        AbstractClientHttpRequest httpRequest = (AbstractClientHttpRequest) clientHttpRequest;
        ContextCarrier contextCarrier = (ContextCarrier) objInst.getSkyWalkingDynamicField();
        CarrierItem next = contextCarrier.items();
        while (next.hasNext()) {
            next = next.next();
            httpRequest.getHeaders().set(next.getHeadKey(), next.getHeadValue());
        }
    }
    return ret;
}
 
Example #2
Source File: RestTemplateIT.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
@Test
public void test1() throws Exception {
    RestTemplate restTemplate = new RestTemplate();
    String forObject = restTemplate.getForObject(webServer.getCallHttpUrl(), String.class);

    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();

    verifier.verifyTrace(event("REST_TEMPLATE", RestTemplate.class.getConstructor()));
    verifier.verifyTrace(event("REST_TEMPLATE", AbstractClientHttpRequest.class.getMethod("execute"), annotation("http.status.code", 200)));
}
 
Example #3
Source File: RestTemplateIT.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
@Test
public void test2() throws Exception {
    RestTemplate restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory());
    String forObject = restTemplate.getForObject(webServer.getCallHttpUrl(), String.class);

    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();

    verifier.verifyTrace(event("REST_TEMPLATE", RestTemplate.class.getConstructor()));
    verifier.verifyTrace(event("REST_TEMPLATE", AbstractClientHttpRequest.class.getMethod("execute"), annotation("http.status.code", 200)));
}