Search in sources :

Example 61 with Request

use of com.squareup.okhttp.Request in project pinpoint by naver.

the class HttpEngineSendRequestMethodInterceptor method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    if (isDebug) {
        logger.afterInterceptor(target, args);
    }
    final Trace trace = traceContext.currentTraceObject();
    if (trace == null) {
        return;
    }
    if (!validate(target)) {
        return;
    }
    try {
        SpanEventRecorder recorder = trace.currentSpanEventRecorder();
        recorder.recordApi(methodDescriptor);
        recorder.recordException(throwable);
        // typeCheck validate();
        Request request = ((UserRequestGetter) target)._$PINPOINT$_getUserRequest();
        if (request != null) {
            try {
                recorder.recordAttribute(AnnotationKey.HTTP_URL, InterceptorUtils.getHttpUrl(request.urlString(), param));
                final String endpoint = getDestinationId(request.url());
                recorder.recordDestinationId(endpoint);
            } catch (Exception ignored) {
                logger.warn("Failed to invoke of request.url(). {}", ignored.getMessage());
            }
            recordRequest(trace, request, throwable);
        }
        // clear attachment.
        InterceptorScopeInvocation invocation = interceptorScope.getCurrentInvocation();
        if (invocation != null && invocation.getAttachment() != null) {
            invocation.removeAttachment();
        }
    } finally {
        trace.traceBlockEnd();
    }
}
Also used : InterceptorScopeInvocation(com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation) Request(com.squareup.okhttp.Request)

Example 62 with Request

use of com.squareup.okhttp.Request in project LookLook by xinghongfei.

the class OkHttpUtils method postRequest.

private void postRequest(String url, final ResultCallback callback, List<Param> params) {
    Request request = buildPostRequest(url, params);
    deliveryResult(callback, request);
}
Also used : Request(com.squareup.okhttp.Request)

Example 63 with Request

use of com.squareup.okhttp.Request in project LookLook by xinghongfei.

the class OkHttpUtils method buildPostRequest.

private Request buildPostRequest(String url, List<Param> params) {
    FormEncodingBuilder builder = new FormEncodingBuilder();
    for (Param param : params) {
        builder.add(param.key, param.value);
    }
    RequestBody requestBody = builder.build();
    return new Request.Builder().url(url).post(requestBody).build();
}
Also used : Request(com.squareup.okhttp.Request) FormEncodingBuilder(com.squareup.okhttp.FormEncodingBuilder) RequestBody(com.squareup.okhttp.RequestBody)

Example 64 with Request

use of com.squareup.okhttp.Request in project ETSMobile-Android2 by ApplETS.

the class AppletsApiSponsorRequest method loadDataFromNetwork.

@Override
public SponsorList loadDataFromNetwork() throws Exception {
    String address = context.getString(R.string.applets_api_sponsors);
    OkHttpClient client = new OkHttpClient();
    Request request = new Request.Builder().url(address).get().build();
    Response response = client.newCall(request).execute();
    String result = response.body().string();
    SponsorList sponsors = new Gson().fromJson(result, SponsorList.class);
    return sponsors;
}
Also used : Response(com.squareup.okhttp.Response) HttpResponse(org.apache.http.HttpResponse) OkHttpClient(com.squareup.okhttp.OkHttpClient) SpringAndroidSpiceRequest(com.octo.android.robospice.request.springandroid.SpringAndroidSpiceRequest) Request(com.squareup.okhttp.Request) Gson(com.google.gson.Gson) SponsorList(ca.etsmtl.applets.etsmobile.model.SponsorList)

Example 65 with Request

use of com.squareup.okhttp.Request in project ETSMobile-Android2 by ApplETS.

the class AppletsApiCalendarRequest method loadDataFromNetwork.

@Override
public EventList loadDataFromNetwork() throws Exception {
    String url = context.getString(R.string.applets_api_calendar, "ets", startDate, endDate);
    OkHttpClient client = new OkHttpClient();
    Request request = new Request.Builder().url(url).get().build();
    Response response = client.newCall(request).execute();
    String calendarJson = response.body().string();
    return new Gson().fromJson(calendarJson, EventList.class);
}
Also used : Response(com.squareup.okhttp.Response) HttpResponse(org.apache.http.HttpResponse) OkHttpClient(com.squareup.okhttp.OkHttpClient) SpringAndroidSpiceRequest(com.octo.android.robospice.request.springandroid.SpringAndroidSpiceRequest) Request(com.squareup.okhttp.Request) Gson(com.google.gson.Gson)

Aggregations

Request (com.squareup.okhttp.Request)73 Response (com.squareup.okhttp.Response)47 IOException (java.io.IOException)41 OkHttpClient (com.squareup.okhttp.OkHttpClient)22 RequestBody (com.squareup.okhttp.RequestBody)18 UnsupportedEncodingException (java.io.UnsupportedEncodingException)12 FormEncodingBuilder (com.squareup.okhttp.FormEncodingBuilder)11 File (java.io.File)10 Callback (com.squareup.okhttp.Callback)9 InputStream (java.io.InputStream)6 Gson (com.google.gson.Gson)4 SpringAndroidSpiceRequest (com.octo.android.robospice.request.springandroid.SpringAndroidSpiceRequest)4 MediaType (com.squareup.okhttp.MediaType)4 ResponseBody (com.squareup.okhttp.ResponseBody)4 FileOutputStream (java.io.FileOutputStream)4 Intent (android.content.Intent)3 SharedPreferences (android.content.SharedPreferences)3 Uri (android.net.Uri)3 Cache (com.squareup.okhttp.Cache)3 Call (com.squareup.okhttp.Call)3