KeyBaseLib response Client
This commit is contained in:
parent
26bfe06d80
commit
7b97c2bbed
|
@ -119,7 +119,7 @@ public class LinkedIdCreateTwitterStep1Fragment extends Fragment {
|
|||
private static Boolean checkHandle(String handle) {
|
||||
try {
|
||||
HttpURLConnection nection =
|
||||
(HttpURLConnection) new URL("https://twitter.com/" + handle).openConnection();
|
||||
(HttpURLConnection) new URL("https://twitter.com/" + handle).getUrlResponse();
|
||||
nection.setRequestMethod("HEAD");
|
||||
nection.setRequestProperty("User-Agent", "OpenKeychain");
|
||||
return nection.getResponseCode() == 200;
|
||||
|
|
|
@ -22,6 +22,8 @@ import com.textuality.keybase.lib.KeybaseUrlConnectionClient;
|
|||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.OkUrlFactory;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -34,16 +36,12 @@ import java.net.URLConnection;
|
|||
*/
|
||||
public class OkHttpKeybaseClient implements KeybaseUrlConnectionClient {
|
||||
|
||||
private OkUrlFactory generateUrlFactory() {
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
return new OkUrlFactory(client);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public URLConnection openConnection(URL url, Proxy proxy, boolean isKeybase) throws IOException {
|
||||
OkHttpClient client = OkHttpClientFactory.getSimpleClient();
|
||||
public Response getUrlResponse(URL url, Proxy proxy, boolean isKeybase) throws IOException {
|
||||
OkHttpClient client = null;
|
||||
|
||||
OkUrlFactory factory = generateUrlFactory();
|
||||
try {
|
||||
if (isKeybase && proxy != null) {
|
||||
client = OkHttpClientFactory.getPinnedClient(url, proxy);
|
||||
|
@ -56,9 +54,11 @@ public class OkHttpKeybaseClient implements KeybaseUrlConnectionClient {
|
|||
Log.e(Constants.TAG, "TlsHelper failed", e);
|
||||
throw new IOException("TlsHelper failed");
|
||||
}
|
||||
factory.setClient(client);
|
||||
|
||||
return factory.open(url);
|
||||
Request request = new Request.Builder()
|
||||
.url(url).build();
|
||||
okhttp3.Response okResponse = client.newCall(request).execute();
|
||||
return new Response(okResponse.body().byteStream(),okResponse.code(),okResponse.message(), okResponse.headers().toMultimap());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue