use of zipkin2.Call in project okhttp by square.
the class HttpOverHttp2Test method sendRequestCookies.
@Test
public void sendRequestCookies() throws Exception {
RecordingCookieJar cookieJar = new RecordingCookieJar();
Cookie requestCookie = new Cookie.Builder().name("a").value("b").domain(server.getHostName()).build();
cookieJar.enqueueRequestCookies(requestCookie);
client = client.newBuilder().cookieJar(cookieJar).build();
server.enqueue(new MockResponse());
Call call = client.newCall(new Request.Builder().url(server.url("/")).build());
Response response = call.execute();
assertEquals("", response.body().string());
RecordedRequest request = server.takeRequest();
assertEquals("a=b", request.getHeader("Cookie"));
}
use of zipkin2.Call in project okhttp by square.
the class OkHttpURLConnection method connect.
@Override
public void connect() throws IOException {
if (executed)
return;
Call call = buildCall();
executed = true;
call.enqueue(this);
synchronized (lock) {
try {
while (connectPending && response == null && callFailure == null) {
// Wait 'til the network interceptor is reached or the call fails.
lock.wait();
}
if (callFailure != null) {
throw propagate(callFailure);
}
} catch (InterruptedException e) {
throw new InterruptedIOException();
}
}
}
use of zipkin2.Call in project okhttp by square.
the class OkHttpURLConnection method getResponse.
/**
* Aggressively tries to get the final HTTP response, potentially making many HTTP requests in the
* process in order to cope with redirects and authentication.
*/
private Response getResponse(boolean networkResponseOnError) throws IOException {
synchronized (lock) {
if (response != null)
return response;
if (callFailure != null) {
if (networkResponseOnError && networkResponse != null)
return networkResponse;
throw propagate(callFailure);
}
}
Call call = buildCall();
networkInterceptor.proceed();
OutputStreamRequestBody requestBody = (OutputStreamRequestBody) call.request().body();
if (requestBody != null)
requestBody.outputStream().close();
if (executed) {
synchronized (lock) {
try {
while (response == null && callFailure == null) {
// Wait until the response is returned or the call fails.
lock.wait();
}
} catch (InterruptedException e) {
throw new InterruptedIOException();
}
}
} else {
executed = true;
try {
onResponse(call, call.execute());
} catch (IOException e) {
onFailure(call, e);
}
}
synchronized (lock) {
if (callFailure != null)
throw propagate(callFailure);
if (response != null)
return response;
}
throw new AssertionError();
}
use of zipkin2.Call in project WeexErosFramework by bmfe.
the class MultipleFileDownloader method execute.
public void execute() {
if (mList == null)
return;
AxiosManager axiosManager = ManagerFactory.getManagerService(AxiosManager.class);
for (final String url : mList) {
final String fileName = createFileName(url);
axiosManager.download(url, new FileCallBack(mPath, fileName) {
@Override
public void onError(Call call, Exception e, int id) {
mSize++;
Log.e("url", "error" + url);
erros.add(new FileItem(new File(mPath, fileName).getAbsolutePath(), fileName));
postResult(mSize);
}
@Override
public void onResponse(File response, int id) {
mSize++;
Log.e("url", url);
paths.add(new FileItem(new File(mPath, fileName).getAbsolutePath(), fileName));
postResult(mSize);
}
});
}
}
use of zipkin2.Call in project MVP by yuchengren.
the class OkHttpUtil method doRequest.
public String doRequest(Request request) throws Exception {
Call call = mOkHttpClient.newCall(request);
Response response = call.execute();
if (response.code() != 200) {
throw new RuntimeException("OkHttpUtil.doRequest(),response code is +" + response.code());
}
ResponseBody responseBody = response.body();
if (responseBody == null) {
throw new RuntimeException("OkHttpUtil.doRequest(),response.Body() is null!");
}
String responseBodyString = responseBody.string();
if (responseBodyString == null) {
throw new RuntimeException("OkHttpUtil.doRequest(),responseBody.string() is null!");
}
return responseBodyString;
}
Aggregations