Search in sources :

Example 31 with Response

use of com.yahoo.vespa.clustercontroller.core.restapiv2.Response in project sonarqube by SonarSource.

the class HttpHeadersTest method verify_headers_of_css.

@Test
public void verify_headers_of_css() throws Exception {
    Response response = call(orchestrator.getServer().getUrl() + "/css/sonar." + JS_HASH + ".css");
    verifySecurityHeaders(response);
    verifyContentType(response, "text/css");
    assertCacheInBrowser(response);
}
Also used : Response(okhttp3.Response) Test(org.junit.Test)

Example 32 with Response

use of com.yahoo.vespa.clustercontroller.core.restapiv2.Response in project sonarqube by SonarSource.

the class CeHttpServerTest method return_http_response_with_code_404_and_exception_message_as_body_when_url_has_no_matching_action.

@Test
public void return_http_response_with_code_404_and_exception_message_as_body_when_url_has_no_matching_action() throws IOException {
    String action = "/dfdsfdsfsdsd";
    Response response = call(underTest.getUrl() + action);
    assertThat(response.code()).isEqualTo(404);
    assertThat(response.body().string()).isEqualTo("Error 404, '" + action + "' not found.");
}
Also used : Response(okhttp3.Response) Test(org.junit.Test)

Example 33 with Response

use of com.yahoo.vespa.clustercontroller.core.restapiv2.Response in project zipkin by openzipkin.

the class AWSSignatureVersion4 method intercept.

@Override
public Response intercept(Chain chain) throws IOException {
    Request input = chain.request();
    Request signed = sign(input);
    Response response = chain.proceed(signed);
    if (response.code() == 403) {
        try (ResponseBody body = response.body()) {
            JsonReader message = enterPath(JsonReader.of(body.source()), "message");
            if (message != null)
                throw new IllegalStateException(message.nextString());
        }
        throw new IllegalStateException(response.toString());
    }
    return response;
}
Also used : Response(okhttp3.Response) Request(okhttp3.Request) JsonReader(com.squareup.moshi.JsonReader) ResponseBody(okhttp3.ResponseBody)

Example 34 with Response

use of com.yahoo.vespa.clustercontroller.core.restapiv2.Response in project Pokemap by omkarmoghe.

the class GoogleManager method refreshToken.

public void refreshToken(String refreshToken, final RefreshListener listener) {
    HttpUrl url = HttpUrl.parse(OAUTH_TOKEN_ENDPOINT).newBuilder().addQueryParameter("client_id", CLIENT_ID).addQueryParameter("client_secret", SECRET).addQueryParameter("refresh_token", refreshToken).addQueryParameter("grant_type", "refresh_token").build();
    Callback<GoogleService.TokenResponse> googleCallback = new Callback<GoogleService.TokenResponse>() {

        @Override
        public void onResponse(Call<GoogleService.TokenResponse> call, Response<GoogleService.TokenResponse> response) {
            if (response != null && response.body() != null) {
                listener.refreshSuccessful(response.body().getIdToken(), response.body().getRefreshToken());
            } else {
                listener.refreshFailed("Failed on requesting the id token");
            }
        }

        @Override
        public void onFailure(Call<GoogleService.TokenResponse> call, Throwable t) {
            t.printStackTrace();
            listener.refreshFailed("Failed on requesting the id token");
        }
    };
    if (mGoogleService != null) {
        Call<GoogleService.TokenResponse> call = mGoogleService.requestToken(url.toString());
        call.enqueue(googleCallback);
    }
}
Also used : Response(retrofit2.Response) Call(retrofit2.Call) Callback(retrofit2.Callback) HttpUrl(okhttp3.HttpUrl)

Example 35 with Response

use of com.yahoo.vespa.clustercontroller.core.restapiv2.Response in project Pokemap by omkarmoghe.

the class NetworkRequestLoggingInterceptor method intercept.

@Override
public Response intercept(Interceptor.Chain chain) throws IOException {
    final Request request = chain.request();
    // Log request
    Log.d(TAG, MessageFormat.format(REQUEST_SEND_LOG, request.method(), sanitize(request.url()), chain.connection(), request.headers()));
    if (request.method().compareToIgnoreCase("post") == 0)
        Log.d(TAG, MessageFormat.format(REQUEST_BODY_LOG, convertRequestBodyToString(request)));
    final long requestStart = System.currentTimeMillis();
    final Response response = chain.proceed(request);
    final long requestEnd = System.currentTimeMillis();
    final long responseTime = requestEnd - requestStart;
    // Log response
    Log.d(TAG, MessageFormat.format(RESPONSE_RECEIVE_LOG, responseTime, sanitize(response.request().url()), response.headers()));
    final String responseBodyString = response.body().string();
    if (responseBodyString.length() > 0)
        Log.d(TAG, MessageFormat.format(RESPONSE_BODY_LOG, responseBodyString.trim()));
    return response.newBuilder().body(ResponseBody.create(response.body().contentType(), responseBodyString)).build();
}
Also used : Response(okhttp3.Response) Request(okhttp3.Request)

Aggregations

Response (okhttp3.Response)1083 Request (okhttp3.Request)814 IOException (java.io.IOException)434 Test (org.junit.Test)330 Response (retrofit2.Response)319 Call (okhttp3.Call)236 ResponseBody (okhttp3.ResponseBody)208 OkHttpClient (okhttp3.OkHttpClient)192 ServiceResponse (com.microsoft.rest.ServiceResponse)179 RequestBody (okhttp3.RequestBody)128 Observable (rx.Observable)116 Callback (okhttp3.Callback)111 MockResponse (okhttp3.mockwebserver.MockResponse)93 List (java.util.List)89 HttpUrl (okhttp3.HttpUrl)81 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)72 TypeToken (com.google.common.reflect.TypeToken)71 ArrayList (java.util.ArrayList)71 File (java.io.File)70 JSONObject (org.json.JSONObject)65