use of okhttp3.Request 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 okhttp3.Request in project zipkin by openzipkin.
the class AWSSignatureVersion4Test method unwrapsJsonError.
@Test
public void unwrapsJsonError() throws InterruptedException, IOException {
// makes sure this isn't wrapped.
thrown.expect(IllegalStateException.class);
thrown.expectMessage("The request signature we calculated does not match the signature you provided.");
es.enqueue(new MockResponse().setResponseCode(403).setBody("{\"message\":\"The request signature we calculated does not match the signature you provided.\"}"));
client.newCall(new Request.Builder().url(es.url("/_template/zipkin_template")).build()).execute();
}
use of okhttp3.Request in project zipkin by openzipkin.
the class HttpCallTest method propagatesOnDispatcherThreadWhenFatal.
@Test
public void propagatesOnDispatcherThreadWhenFatal() throws Exception {
mws.enqueue(new MockResponse());
http.newCall(request, b -> {
throw new LinkageError();
}).submit(callback);
SimpleTimeLimiter timeLimiter = new SimpleTimeLimiter();
try {
timeLimiter.callWithTimeout(callback::get, 100, TimeUnit.MILLISECONDS, true);
failBecauseExceptionWasNotThrown(UncheckedTimeoutException.class);
} catch (UncheckedTimeoutException expected) {
}
}
use of okhttp3.Request in project zipkin by openzipkin.
the class HttpCallTest method executionException_conversionException.
@Test
public void executionException_conversionException() throws Exception {
mws.enqueue(new MockResponse());
http.newCall(request, b -> {
throw new IllegalArgumentException("eeek");
}).submit(callback);
try {
callback.get();
failBecauseExceptionWasNotThrown(IllegalArgumentException.class);
} catch (IllegalArgumentException expected) {
assertThat(expected).isInstanceOf(IllegalArgumentException.class);
}
}
use of okhttp3.Request in project zipkin by openzipkin.
the class ElasticsearchHttpStorage method flush.
/** This is a blocking call, only used in tests. */
static void flush(HttpCall.Factory factory, String index) throws IOException {
Request flushRequest = new Request.Builder().url(factory.baseUrl.newBuilder().addPathSegment(index).addPathSegment("_flush").build()).post(RequestBody.create(APPLICATION_JSON, "")).tag("flush-index").build();
factory.execute(flushRequest, b -> null);
}
Aggregations