Search in sources :

Example 1 with RealCall

use of okhttp3.internal.connection.RealCall in project bithon by FrankChen021.

the class RealCall$GetResponseWithInterceptorChain method onMethodEnter.

@Override
public InterceptionDecision onMethodEnter(AopContext aopContext) {
    Call realCall = (Call) aopContext.getTarget();
    Request request = realCall.request();
    String uri = request.url().uri().toString().split("\\?")[0];
    return needIgnore(uri) ? InterceptionDecision.SKIP_LEAVE : InterceptionDecision.CONTINUE;
}
Also used : Call(okhttp3.Call) Request(okhttp3.Request)

Example 2 with RealCall

use of okhttp3.internal.connection.RealCall in project bithon by FrankChen021.

the class RealCall$GetResponseWithInterceptorChain method onMethodLeave.

@Override
public void onMethodLeave(AopContext aopContext) {
    Call realCall = (Call) aopContext.getTarget();
    Request originRequest = realCall.request();
    String requestUri = originRequest.url().uri().toString();
    String requestMethod = originRequest.method().toUpperCase(Locale.ENGLISH);
    if (aopContext.getException() != null) {
        metricRegistry.addExceptionRequest(requestUri, requestMethod, aopContext.getCostTime());
    } else {
        Response response = aopContext.castReturningAs();
        metricRegistry.addRequest(requestUri, requestMethod, response.code(), aopContext.getCostTime());
    }
    addBytes(requestUri, requestMethod, originRequest, realCall);
}
Also used : Response(okhttp3.Response) Call(okhttp3.Call) Request(okhttp3.Request)

Example 3 with RealCall

use of okhttp3.internal.connection.RealCall in project bithon by FrankChen021.

the class RealCall$GetResponseWithInterceptorChain method onMethodEnter.

@Override
public InterceptionDecision onMethodEnter(AopContext aopContext) {
    Call realCall = aopContext.castTargetAs();
    Request originRequest = realCall.request();
    String uri = originRequest.url().uri().toString().split("\\?")[0];
    return needIgnore(uri) ? InterceptionDecision.SKIP_LEAVE : InterceptionDecision.CONTINUE;
}
Also used : Call(okhttp3.Call) Request(okhttp3.Request)

Example 4 with RealCall

use of okhttp3.internal.connection.RealCall in project cloudant-java-sdk by IBM.

the class SdkTimeoutTest method testBasicAuthTimeout.

@Test
void testBasicAuthTimeout() throws NoSuchFieldException, IllegalAccessException {
    BasicAuthenticator basicAuth = new BasicAuthenticator.Builder().username("user").password("psw").build();
    CloudantBaseService myService = createCloudantBaseService(basicAuth, "https://cloudant.example");
    Request testRequest = createTestRequest(myService);
    for (int i = 0; i < 2; i++) {
        if (i == 1) {
            setCustomTimeout(myService, testCases[i]);
        }
        RealCall testRequestCall = createServiceCall(myService, testRequest);
        assertEquals(TimeUnit.MILLISECONDS.toSeconds(testRequestCall.getClient().readTimeoutMillis()), testCases[i]);
    }
}
Also used : RealCall(okhttp3.internal.connection.RealCall) BasicAuthenticator(com.ibm.cloud.sdk.core.security.BasicAuthenticator) Request(okhttp3.Request) Test(org.testng.annotations.Test)

Example 5 with RealCall

use of okhttp3.internal.connection.RealCall in project cloudant-java-sdk by IBM.

the class SdkTimeoutTest method testNoAuthTimeout.

// Test implementations
@Test
void testNoAuthTimeout() throws NoSuchFieldException, IllegalAccessException {
    NoAuthAuthenticator noAuth = new NoAuthAuthenticator();
    CloudantBaseService myService = createCloudantBaseService(noAuth, "https://cloudant.example");
    Request testRequest = createTestRequest(myService);
    for (int i = 0; i < 2; i++) {
        if (i == 1) {
            setCustomTimeout(myService, testCases[i]);
        }
        RealCall testRequestCall = createServiceCall(myService, testRequest);
        assertEquals(TimeUnit.MILLISECONDS.toSeconds(testRequestCall.getClient().readTimeoutMillis()), testCases[i]);
    }
}
Also used : NoAuthAuthenticator(com.ibm.cloud.sdk.core.security.NoAuthAuthenticator) RealCall(okhttp3.internal.connection.RealCall) Request(okhttp3.Request) Test(org.testng.annotations.Test)

Aggregations

Request (okhttp3.Request)21 Response (okhttp3.Response)11 OkHttpClient (okhttp3.OkHttpClient)10 PluginTestVerifier (com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier)8 Method (java.lang.reflect.Method)8 Call (okhttp3.Call)8 Test (org.junit.Test)8 IOException (java.io.IOException)6 Callback (okhttp3.Callback)5 RealCall (okhttp3.internal.connection.RealCall)5 CountDownLatch (java.util.concurrent.CountDownLatch)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 Test (org.testng.annotations.Test)4 Field (java.lang.reflect.Field)2 EnhancedInstance (org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance)2 Request (com.android.volley.Request)1 StringRequest (com.android.volley.toolbox.StringRequest)1 CouchDbSessionAuthenticator (com.ibm.cloud.cloudant.security.CouchDbSessionAuthenticator)1 BasicAuthenticator (com.ibm.cloud.sdk.core.security.BasicAuthenticator)1 IamAuthenticator (com.ibm.cloud.sdk.core.security.IamAuthenticator)1