OkUrlFactory.java
2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package com.squareup.okhttp;
import com.squareup.okhttp.internal.huc.HttpURLConnectionImpl;
import com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl;
import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
import java.net.URLStreamHandlerFactory;
public final class OkUrlFactory
implements Cloneable, URLStreamHandlerFactory
{
private final OkHttpClient client;
public OkUrlFactory(OkHttpClient paramOkHttpClient)
{
this.client = paramOkHttpClient;
}
public final OkHttpClient client()
{
return this.client;
}
public final OkUrlFactory clone()
{
return new OkUrlFactory(this.client.clone());
}
public final URLStreamHandler createURLStreamHandler(final String paramString)
{
if ((!paramString.equals("http")) && (!paramString.equals("https"))) {
return null;
}
new URLStreamHandler()
{
protected int getDefaultPort()
{
if (paramString.equals("http")) {
return 80;
}
if (paramString.equals("https")) {
return 443;
}
throw new AssertionError();
}
protected URLConnection openConnection(URL paramAnonymousURL)
{
return OkUrlFactory.this.open(paramAnonymousURL);
}
protected URLConnection openConnection(URL paramAnonymousURL, Proxy paramAnonymousProxy)
{
return OkUrlFactory.this.open(paramAnonymousURL, paramAnonymousProxy);
}
};
}
public final HttpURLConnection open(URL paramURL)
{
return open(paramURL, this.client.getProxy());
}
final HttpURLConnection open(URL paramURL, Proxy paramProxy)
{
String str = paramURL.getProtocol();
OkHttpClient localOkHttpClient = this.client.copyWithDefaults();
localOkHttpClient.setProxy(paramProxy);
if (str.equals("http")) {
return new HttpURLConnectionImpl(paramURL, localOkHttpClient);
}
if (str.equals("https")) {
return new HttpsURLConnectionImpl(paramURL, localOkHttpClient);
}
throw new IllegalArgumentException("Unexpected protocol: " + str);
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/squareup/okhttp/OkUrlFactory.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/