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);
}
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.");
}
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;
}
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);
}
}
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();
}
Aggregations