Search in sources :

Example 51 with Protocol

use of okhttp3.Protocol in project NoHttp by yanzhenjie.

the class URLConnectionFactory method open.

/**
     * Open url.
     *
     * @param url   {@link URL}.
     * @param proxy {@link Proxy}.
     * @return {@link HttpURLConnection}.
     */
public HttpURLConnection open(URL url, Proxy proxy) {
    OkHttpClient copy = mClient.newBuilder().proxy(proxy).build();
    String protocol = url.getProtocol();
    if (protocol.equals("http"))
        return new OkHttpURLConnection(url, copy);
    if (protocol.equals("https"))
        return new OkHttpsURLConnection(url, copy);
    throw new IllegalArgumentException("Unexpected protocol: " + protocol);
}
Also used : OkHttpClient(okhttp3.OkHttpClient) OkHttpsURLConnection(okhttp3.internal.huc.OkHttpsURLConnection) OkHttpURLConnection(okhttp3.internal.huc.OkHttpURLConnection)

Example 52 with Protocol

use of okhttp3.Protocol in project Rocket.Chat.Android by RocketChat.

the class DefaultServerPolicyApi method getApiInfo.

private Flowable<Response<JSONObject>> getApiInfo(@NonNull String protocol) {
    return Flowable.create(responseEmitter -> {
        final Call call = client.newCall(createRequest(protocol));
        call.enqueue(getOkHttpCallback(responseEmitter, protocol));
        responseEmitter.setCancellable(call::cancel);
    }, BackpressureStrategy.LATEST);
}
Also used : Call(okhttp3.Call)

Aggregations

Request (okhttp3.Request)26 Response (okhttp3.Response)26 Test (org.junit.Test)25 ResponseBody (okhttp3.ResponseBody)20 IOException (java.io.IOException)18 Protocol (okhttp3.Protocol)14 Buffer (okio.Buffer)13 HttpResponse (com.facebook.buck.slb.HttpResponse)12 LazyPath (com.facebook.buck.io.LazyPath)11 RuleKey (com.facebook.buck.rules.RuleKey)11 Path (java.nio.file.Path)11 OkHttpResponseWrapper (com.facebook.buck.slb.OkHttpResponseWrapper)10 List (java.util.List)10 MediaType (okhttp3.MediaType)10 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)9 HttpURLConnection (java.net.HttpURLConnection)9 MockResponse (okhttp3.mockwebserver.MockResponse)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)8 DataOutputStream (java.io.DataOutputStream)7 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)7