mirror of
https://github.com/square/okhttp.git
synced 2025-11-24 18:41:06 +03:00
Sort more imports and wrap documentation at 100 columns.
This is a mechanical refactoring. The only thing I had trouble with is IntelliJ's weak support for `<ul>` tags in Javadoc.
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
|||||||
@@ -38,11 +38,11 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
|||||||
import org.bouncycastle.x509.X509V3CertificateGenerator;
|
import org.bouncycastle.x509.X509V3CertificateGenerator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an SSL context for testing. This uses Bouncy Castle to generate a
|
* Constructs an SSL context for testing. This uses Bouncy Castle to generate a self-signed
|
||||||
* self-signed certificate for a single hostname such as "localhost".
|
* certificate for a single hostname such as "localhost".
|
||||||
*
|
*
|
||||||
* <p>The crypto performed by this class is relatively slow. Clients should
|
* <p>The crypto performed by this class is relatively slow. Clients should reuse SSL context
|
||||||
* reuse SSL context instances where possible.
|
* instances where possible.
|
||||||
*/
|
*/
|
||||||
public final class SslContextBuilder {
|
public final class SslContextBuilder {
|
||||||
static {
|
static {
|
||||||
@@ -57,8 +57,8 @@ public final class SslContextBuilder {
|
|||||||
private long notAfter = System.currentTimeMillis() + ONE_DAY_MILLIS;
|
private long notAfter = System.currentTimeMillis() + ONE_DAY_MILLIS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param hostName the subject of the host. For TLS this should be the
|
* @param hostName the subject of the host. For TLS this should be the domain name that the client
|
||||||
* domain name that the client uses to identify the server.
|
* uses to identify the server.
|
||||||
*/
|
*/
|
||||||
public SslContextBuilder(String hostName) {
|
public SslContextBuilder(String hostName) {
|
||||||
this.hostName = hostName;
|
this.hostName = hostName;
|
||||||
@@ -87,7 +87,7 @@ public final class SslContextBuilder {
|
|||||||
|
|
||||||
// Put 'em in a key store.
|
// Put 'em in a key store.
|
||||||
KeyStore keyStore = newEmptyKeyStore(password);
|
KeyStore keyStore = newEmptyKeyStore(password);
|
||||||
Certificate[] certificateChain = { certificate };
|
Certificate[] certificateChain = {certificate};
|
||||||
keyStore.setKeyEntry("private", keyPair.getPrivate(), password, certificateChain);
|
keyStore.setKeyEntry("private", keyPair.getPrivate(), password, certificateChain);
|
||||||
keyStore.setCertificateEntry("cert", certificate);
|
keyStore.setCertificateEntry("cert", certificate);
|
||||||
|
|
||||||
@@ -111,8 +111,8 @@ public final class SslContextBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a certificate for {@code hostName} containing {@code keyPair}'s
|
* Generates a certificate for {@code hostName} containing {@code keyPair}'s public key, signed by
|
||||||
* public key, signed by {@code keyPair}'s private key.
|
* {@code keyPair}'s private key.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation") // use the old Bouncy Castle APIs to reduce dependencies.
|
@SuppressWarnings("deprecation") // use the old Bouncy Castle APIs to reduce dependencies.
|
||||||
public X509Certificate selfSignedCertificate(KeyPair keyPair, String serialNumber)
|
public X509Certificate selfSignedCertificate(KeyPair keyPair, String serialNumber)
|
||||||
|
|||||||
@@ -16,10 +16,6 @@
|
|||||||
|
|
||||||
package okhttp3.internal.framed;
|
package okhttp3.internal.framed;
|
||||||
|
|
||||||
import okhttp3.Protocol;
|
|
||||||
import okhttp3.internal.Platform;
|
|
||||||
import okhttp3.internal.SslContextBuilder;
|
|
||||||
import okhttp3.internal.Util;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.ProtocolException;
|
import java.net.ProtocolException;
|
||||||
@@ -31,6 +27,10 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.net.ssl.SSLSocket;
|
import javax.net.ssl.SSLSocket;
|
||||||
import javax.net.ssl.SSLSocketFactory;
|
import javax.net.ssl.SSLSocketFactory;
|
||||||
|
import okhttp3.Protocol;
|
||||||
|
import okhttp3.internal.Platform;
|
||||||
|
import okhttp3.internal.SslContextBuilder;
|
||||||
|
import okhttp3.internal.Util;
|
||||||
import okio.BufferedSink;
|
import okio.BufferedSink;
|
||||||
import okio.Okio;
|
import okio.Okio;
|
||||||
import okio.Source;
|
import okio.Source;
|
||||||
|
|||||||
@@ -18,17 +18,16 @@ package okhttp3.mockwebserver;
|
|||||||
/** Handler for mock server requests. */
|
/** Handler for mock server requests. */
|
||||||
public abstract class Dispatcher {
|
public abstract class Dispatcher {
|
||||||
/**
|
/**
|
||||||
* Returns a response to satisfy {@code request}. This method may block (for
|
* Returns a response to satisfy {@code request}. This method may block (for instance, to wait on
|
||||||
* instance, to wait on a CountdownLatch).
|
* a CountdownLatch).
|
||||||
*/
|
*/
|
||||||
public abstract MockResponse dispatch(RecordedRequest request) throws InterruptedException;
|
public abstract MockResponse dispatch(RecordedRequest request) throws InterruptedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an early guess of the next response, used for policy on how an
|
* Returns an early guess of the next response, used for policy on how an incoming request should
|
||||||
* incoming request should be received. The default implementation returns an
|
* be received. The default implementation returns an empty response. Mischievous implementations
|
||||||
* empty response. Mischievous implementations can return other values to test
|
* can return other values to test HTTP edge cases, such as unhappy socket policies or throttled
|
||||||
* HTTP edge cases, such as unhappy socket policies or throttled request
|
* request bodies.
|
||||||
* bodies.
|
|
||||||
*/
|
*/
|
||||||
public MockResponse peek() {
|
public MockResponse peek() {
|
||||||
return new MockResponse().setSocketPolicy(SocketPolicy.KEEP_OPEN);
|
return new MockResponse().setSocketPolicy(SocketPolicy.KEEP_OPEN);
|
||||||
|
|||||||
@@ -15,14 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.mockwebserver;
|
package okhttp3.mockwebserver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import okhttp3.Headers;
|
import okhttp3.Headers;
|
||||||
import okhttp3.internal.Internal;
|
import okhttp3.internal.Internal;
|
||||||
import okhttp3.internal.framed.Settings;
|
import okhttp3.internal.framed.Settings;
|
||||||
import okhttp3.ws.WebSocketListener;
|
import okhttp3.ws.WebSocketListener;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import okhttp3.Protocol;
|
|
||||||
import okio.Buffer;
|
import okio.Buffer;
|
||||||
|
|
||||||
/** A scripted response to be replayed by the mock web server. */
|
/** A scripted response to be replayed by the mock web server. */
|
||||||
@@ -83,8 +82,8 @@ public final class MockResponse implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all HTTP headers including any "Content-Length" and
|
* Removes all HTTP headers including any "Content-Length" and "Transfer-encoding" headers that
|
||||||
* "Transfer-encoding" headers that were added by default.
|
* were added by default.
|
||||||
*/
|
*/
|
||||||
public MockResponse clearHeaders() {
|
public MockResponse clearHeaders() {
|
||||||
headers = new Headers.Builder();
|
headers = new Headers.Builder();
|
||||||
@@ -92,8 +91,8 @@ public final class MockResponse implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds {@code header} as an HTTP header. For well-formed HTTP {@code header}
|
* Adds {@code header} as an HTTP header. For well-formed HTTP {@code header} should contain a
|
||||||
* should contain a name followed by a colon and a value.
|
* name followed by a colon and a value.
|
||||||
*/
|
*/
|
||||||
public MockResponse addHeader(String header) {
|
public MockResponse addHeader(String header) {
|
||||||
headers.add(header);
|
headers.add(header);
|
||||||
@@ -101,8 +100,8 @@ public final class MockResponse implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new header with the name and value. This may be used to add multiple
|
* Adds a new header with the name and value. This may be used to add multiple headers with the
|
||||||
* headers with the same name.
|
* same name.
|
||||||
*/
|
*/
|
||||||
public MockResponse addHeader(String name, Object value) {
|
public MockResponse addHeader(String name, Object value) {
|
||||||
headers.add(name, String.valueOf(value));
|
headers.add(name, String.valueOf(value));
|
||||||
@@ -110,9 +109,9 @@ public final class MockResponse implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new header with the name and value. This may be used to add multiple
|
* Adds a new header with the name and value. This may be used to add multiple headers with the
|
||||||
* headers with the same name. Unlike {@link #addHeader(String, Object)} this
|
* same name. Unlike {@link #addHeader(String, Object)} this does not validate the name and
|
||||||
* does not validate the name and value.
|
* value.
|
||||||
*/
|
*/
|
||||||
public MockResponse addHeaderLenient(String name, Object value) {
|
public MockResponse addHeaderLenient(String name, Object value) {
|
||||||
Internal.instance.addLenient(headers, name, String.valueOf(value));
|
Internal.instance.addLenient(headers, name, String.valueOf(value));
|
||||||
@@ -120,8 +119,7 @@ public final class MockResponse implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all headers named {@code name}, then adds a new header with the
|
* Removes all headers named {@code name}, then adds a new header with the name and value.
|
||||||
* name and value.
|
|
||||||
*/
|
*/
|
||||||
public MockResponse setHeader(String name, Object value) {
|
public MockResponse setHeader(String name, Object value) {
|
||||||
removeHeader(name);
|
removeHeader(name);
|
||||||
@@ -157,8 +155,7 @@ public final class MockResponse implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the response body to {@code body}, chunked every {@code maxChunkSize}
|
* Sets the response body to {@code body}, chunked every {@code maxChunkSize} bytes.
|
||||||
* bytes.
|
|
||||||
*/
|
*/
|
||||||
public MockResponse setChunkedBody(Buffer body, int maxChunkSize) {
|
public MockResponse setChunkedBody(Buffer body, int maxChunkSize) {
|
||||||
removeHeader("Content-Length");
|
removeHeader("Content-Length");
|
||||||
@@ -179,8 +176,8 @@ public final class MockResponse implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the response body to the UTF-8 encoded bytes of {@code body}, chunked
|
* Sets the response body to the UTF-8 encoded bytes of {@code body}, chunked every {@code
|
||||||
* every {@code maxChunkSize} bytes.
|
* maxChunkSize} bytes.
|
||||||
*/
|
*/
|
||||||
public MockResponse setChunkedBody(String body, int maxChunkSize) {
|
public MockResponse setChunkedBody(String body, int maxChunkSize) {
|
||||||
return setChunkedBody(new Buffer().writeUtf8(body), maxChunkSize);
|
return setChunkedBody(new Buffer().writeUtf8(body), maxChunkSize);
|
||||||
@@ -215,8 +212,8 @@ public final class MockResponse implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the delayed time of the response body to {@code delay}. This applies to the
|
* Set the delayed time of the response body to {@code delay}. This applies to the response body
|
||||||
* response body only; response headers are not affected.
|
* only; response headers are not affected.
|
||||||
*/
|
*/
|
||||||
public MockResponse setBodyDelay(long delay, TimeUnit unit) {
|
public MockResponse setBodyDelay(long delay, TimeUnit unit) {
|
||||||
bodyDelayAmount = delay;
|
bodyDelayAmount = delay;
|
||||||
@@ -229,9 +226,8 @@ public final class MockResponse implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When {@link MockWebServer#setProtocols(java.util.List) protocols}
|
* When {@link MockWebServer#setProtocols(java.util.List) protocols} include {@linkplain
|
||||||
* include {@linkplain Protocol#HTTP_2}, this attaches a
|
* okhttp3.Protocol#HTTP_2}, this attaches a pushed stream to this response.
|
||||||
* pushed stream to this response.
|
|
||||||
*/
|
*/
|
||||||
public MockResponse withPush(PushPromise promise) {
|
public MockResponse withPush(PushPromise promise) {
|
||||||
this.promises.add(promise);
|
this.promises.add(promise);
|
||||||
@@ -244,9 +240,8 @@ public final class MockResponse implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When {@linkplain MockWebServer#setProtocols(java.util.List) protocols}
|
* When {@linkplain MockWebServer#setProtocols(java.util.List) protocols} include {@linkplain
|
||||||
* include {@linkplain Protocol#HTTP_2 HTTP/2}, this
|
* okhttp3.Protocol#HTTP_2 HTTP/2}, this pushes {@code settings} before writing the response.
|
||||||
* pushes {@code settings} before writing the response.
|
|
||||||
*/
|
*/
|
||||||
public MockResponse withSettings(Settings settings) {
|
public MockResponse withSettings(Settings settings) {
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
|
|||||||
@@ -17,23 +17,6 @@
|
|||||||
|
|
||||||
package okhttp3.mockwebserver;
|
package okhttp3.mockwebserver;
|
||||||
|
|
||||||
import okhttp3.Headers;
|
|
||||||
import okhttp3.HttpUrl;
|
|
||||||
import okhttp3.Protocol;
|
|
||||||
import okhttp3.Request;
|
|
||||||
import okhttp3.Response;
|
|
||||||
import okhttp3.internal.NamedRunnable;
|
|
||||||
import okhttp3.internal.Platform;
|
|
||||||
import okhttp3.internal.Util;
|
|
||||||
import okhttp3.internal.framed.ErrorCode;
|
|
||||||
import okhttp3.internal.framed.FramedConnection;
|
|
||||||
import okhttp3.internal.framed.FramedStream;
|
|
||||||
import okhttp3.internal.framed.Header;
|
|
||||||
import okhttp3.internal.framed.Settings;
|
|
||||||
import okhttp3.internal.http.HttpMethod;
|
|
||||||
import okhttp3.internal.ws.RealWebSocket;
|
|
||||||
import okhttp3.internal.ws.WebSocketProtocol;
|
|
||||||
import okhttp3.ws.WebSocketListener;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
@@ -69,6 +52,23 @@ import javax.net.ssl.SSLSocket;
|
|||||||
import javax.net.ssl.SSLSocketFactory;
|
import javax.net.ssl.SSLSocketFactory;
|
||||||
import javax.net.ssl.TrustManager;
|
import javax.net.ssl.TrustManager;
|
||||||
import javax.net.ssl.X509TrustManager;
|
import javax.net.ssl.X509TrustManager;
|
||||||
|
import okhttp3.Headers;
|
||||||
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.Protocol;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
import okhttp3.internal.NamedRunnable;
|
||||||
|
import okhttp3.internal.Platform;
|
||||||
|
import okhttp3.internal.Util;
|
||||||
|
import okhttp3.internal.framed.ErrorCode;
|
||||||
|
import okhttp3.internal.framed.FramedConnection;
|
||||||
|
import okhttp3.internal.framed.FramedStream;
|
||||||
|
import okhttp3.internal.framed.Header;
|
||||||
|
import okhttp3.internal.framed.Settings;
|
||||||
|
import okhttp3.internal.http.HttpMethod;
|
||||||
|
import okhttp3.internal.ws.RealWebSocket;
|
||||||
|
import okhttp3.internal.ws.WebSocketProtocol;
|
||||||
|
import okhttp3.ws.WebSocketListener;
|
||||||
import okio.Buffer;
|
import okio.Buffer;
|
||||||
import okio.BufferedSink;
|
import okio.BufferedSink;
|
||||||
import okio.BufferedSource;
|
import okio.BufferedSource;
|
||||||
@@ -93,8 +93,8 @@ import static okhttp3.mockwebserver.SocketPolicy.SHUTDOWN_OUTPUT_AT_END;
|
|||||||
import static okhttp3.mockwebserver.SocketPolicy.UPGRADE_TO_SSL_AT_END;
|
import static okhttp3.mockwebserver.SocketPolicy.UPGRADE_TO_SSL_AT_END;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A scriptable web server. Callers supply canned responses and the server
|
* A scriptable web server. Callers supply canned responses and the server replays them upon request
|
||||||
* replays them upon request in sequence.
|
* in sequence.
|
||||||
*/
|
*/
|
||||||
public final class MockWebServer implements TestRule {
|
public final class MockWebServer implements TestRule {
|
||||||
private static final X509TrustManager UNTRUSTED_TRUST_MANAGER = new X509TrustManager() {
|
private static final X509TrustManager UNTRUSTED_TRUST_MANAGER = new X509TrustManager() {
|
||||||
@@ -202,9 +202,8 @@ public final class MockWebServer implements TestRule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a cookie domain for this server. This returns the server's
|
* Returns a cookie domain for this server. This returns the server's non-loopback host name if it
|
||||||
* non-loopback host name if it is known. Otherwise this returns ".local" for
|
* is known. Otherwise this returns ".local" for this server's loopback name.
|
||||||
* this server's loopback name.
|
|
||||||
*/
|
*/
|
||||||
public String getCookieDomain() {
|
public String getCookieDomain() {
|
||||||
String hostName = getHostName();
|
String hostName = getHostName();
|
||||||
@@ -212,29 +211,26 @@ public final class MockWebServer implements TestRule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the number of bytes of the POST body to keep in memory to the given
|
* Sets the number of bytes of the POST body to keep in memory to the given limit.
|
||||||
* limit.
|
|
||||||
*/
|
*/
|
||||||
public void setBodyLimit(long maxBodyLength) {
|
public void setBodyLimit(long maxBodyLength) {
|
||||||
this.bodyLimit = maxBodyLength;
|
this.bodyLimit = maxBodyLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether ALPN is used on incoming HTTPS connections to
|
* Sets whether ALPN is used on incoming HTTPS connections to negotiate a protocol like HTTP/1.1
|
||||||
* negotiate a protocol like HTTP/1.1 or HTTP/2. Call this method to disable
|
* or HTTP/2. Call this method to disable negotiation and restrict connections to HTTP/1.1.
|
||||||
* negotiation and restrict connections to HTTP/1.1.
|
|
||||||
*/
|
*/
|
||||||
public void setProtocolNegotiationEnabled(boolean protocolNegotiationEnabled) {
|
public void setProtocolNegotiationEnabled(boolean protocolNegotiationEnabled) {
|
||||||
this.protocolNegotiationEnabled = protocolNegotiationEnabled;
|
this.protocolNegotiationEnabled = protocolNegotiationEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates the protocols supported by ALPN on incoming HTTPS
|
* Indicates the protocols supported by ALPN on incoming HTTPS connections. This list is ignored
|
||||||
* connections. This list is ignored when
|
* when {@link #setProtocolNegotiationEnabled negotiation is disabled}.
|
||||||
* {@link #setProtocolNegotiationEnabled negotiation is disabled}.
|
|
||||||
*
|
*
|
||||||
* @param protocols the protocols to use, in order of preference. The list
|
* @param protocols the protocols to use, in order of preference. The list must contain
|
||||||
* must contain {@linkplain Protocol#HTTP_1_1}. It must not contain null.
|
* {@linkplain Protocol#HTTP_1_1}. It must not contain null.
|
||||||
*/
|
*/
|
||||||
public void setProtocols(List<Protocol> protocols) {
|
public void setProtocols(List<Protocol> protocols) {
|
||||||
protocols = Util.immutableList(protocols);
|
protocols = Util.immutableList(protocols);
|
||||||
@@ -250,8 +246,7 @@ public final class MockWebServer implements TestRule {
|
|||||||
/**
|
/**
|
||||||
* Serve requests with HTTPS rather than otherwise.
|
* Serve requests with HTTPS rather than otherwise.
|
||||||
*
|
*
|
||||||
* @param tunnelProxy true to expect the HTTP CONNECT method before
|
* @param tunnelProxy true to expect the HTTP CONNECT method before negotiating TLS.
|
||||||
* negotiating TLS.
|
|
||||||
*/
|
*/
|
||||||
public void useHttps(SSLSocketFactory sslSocketFactory, boolean tunnelProxy) {
|
public void useHttps(SSLSocketFactory sslSocketFactory, boolean tunnelProxy) {
|
||||||
this.sslSocketFactory = sslSocketFactory;
|
this.sslSocketFactory = sslSocketFactory;
|
||||||
@@ -259,9 +254,9 @@ public final class MockWebServer implements TestRule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Awaits the next HTTP request, removes it, and returns it. Callers should
|
* Awaits the next HTTP request, removes it, and returns it. Callers should use this to verify the
|
||||||
* use this to verify the request was sent as intended. This method will block until the
|
* request was sent as intended. This method will block until the request is available, possibly
|
||||||
* request is available, possibly forever.
|
* forever.
|
||||||
*
|
*
|
||||||
* @return the head of the request queue
|
* @return the head of the request queue
|
||||||
*/
|
*/
|
||||||
@@ -270,14 +265,12 @@ public final class MockWebServer implements TestRule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Awaits the next HTTP request (waiting up to the
|
* Awaits the next HTTP request (waiting up to the specified wait time if necessary), removes it,
|
||||||
* specified wait time if necessary), removes it, and returns it. Callers should
|
* and returns it. Callers should use this to verify the request was sent as intended within the
|
||||||
* use this to verify the request was sent as intended within the given time.
|
* given time.
|
||||||
*
|
*
|
||||||
* @param timeout how long to wait before giving up, in units of
|
* @param timeout how long to wait before giving up, in units of {@code unit}
|
||||||
* {@code unit}
|
* @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter
|
||||||
* @param unit a {@code TimeUnit} determining how to interpret the
|
|
||||||
* {@code timeout} parameter
|
|
||||||
* @return the head of the request queue
|
* @return the head of the request queue
|
||||||
*/
|
*/
|
||||||
public RecordedRequest takeRequest(long timeout, TimeUnit unit) throws InterruptedException {
|
public RecordedRequest takeRequest(long timeout, TimeUnit unit) throws InterruptedException {
|
||||||
@@ -285,21 +278,20 @@ public final class MockWebServer implements TestRule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of HTTP requests received thus far by this server. This
|
* Returns the number of HTTP requests received thus far by this server. This may exceed the
|
||||||
* may exceed the number of HTTP connections when connection reuse is in
|
* number of HTTP connections when connection reuse is in practice.
|
||||||
* practice.
|
|
||||||
*/
|
*/
|
||||||
public int getRequestCount() {
|
public int getRequestCount() {
|
||||||
return requestCount.get();
|
return requestCount.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scripts {@code response} to be returned to a request made in sequence. The
|
* Scripts {@code response} to be returned to a request made in sequence. The first request is
|
||||||
* first request is served by the first enqueued response; the second request
|
* served by the first enqueued response; the second request by the second enqueued response; and
|
||||||
* by the second enqueued response; and so on.
|
* so on.
|
||||||
*
|
*
|
||||||
* @throws ClassCastException if the default dispatcher has been replaced
|
* @throws ClassCastException if the default dispatcher has been replaced with {@link
|
||||||
* with {@link #setDispatcher(Dispatcher)}.
|
* #setDispatcher(Dispatcher)}.
|
||||||
*/
|
*/
|
||||||
public void enqueue(MockResponse response) {
|
public void enqueue(MockResponse response) {
|
||||||
((QueueDispatcher) dispatcher).enqueueResponse(response.clone());
|
((QueueDispatcher) dispatcher).enqueueResponse(response.clone());
|
||||||
@@ -313,9 +305,8 @@ public final class MockWebServer implements TestRule {
|
|||||||
/**
|
/**
|
||||||
* Starts the server on the loopback interface for the given port.
|
* Starts the server on the loopback interface for the given port.
|
||||||
*
|
*
|
||||||
* @param port the port to listen to, or 0 for any available port. Automated
|
* @param port the port to listen to, or 0 for any available port. Automated tests should always
|
||||||
* tests should always use port 0 to avoid flakiness when a specific port
|
* use port 0 to avoid flakiness when a specific port is unavailable.
|
||||||
* is unavailable.
|
|
||||||
*/
|
*/
|
||||||
public void start(int port) throws IOException {
|
public void start(int port) throws IOException {
|
||||||
start(InetAddress.getByName("localhost"), port);
|
start(InetAddress.getByName("localhost"), port);
|
||||||
@@ -325,9 +316,8 @@ public final class MockWebServer implements TestRule {
|
|||||||
* Starts the server on the given address and port.
|
* Starts the server on the given address and port.
|
||||||
*
|
*
|
||||||
* @param inetAddress the address to create the server socket on
|
* @param inetAddress the address to create the server socket on
|
||||||
* @param port the port to listen to, or 0 for any available port. Automated
|
* @param port the port to listen to, or 0 for any available port. Automated tests should always
|
||||||
* tests should always use port 0 to avoid flakiness when a specific port
|
* use port 0 to avoid flakiness when a specific port is unavailable.
|
||||||
* is unavailable.
|
|
||||||
*/
|
*/
|
||||||
public void start(InetAddress inetAddress, int port) throws IOException {
|
public void start(InetAddress inetAddress, int port) throws IOException {
|
||||||
start(new InetSocketAddress(inetAddress, port));
|
start(new InetSocketAddress(inetAddress, port));
|
||||||
@@ -565,7 +555,7 @@ public final class MockWebServer implements TestRule {
|
|||||||
|
|
||||||
private void processHandshakeFailure(Socket raw) throws Exception {
|
private void processHandshakeFailure(Socket raw) throws Exception {
|
||||||
SSLContext context = SSLContext.getInstance("TLS");
|
SSLContext context = SSLContext.getInstance("TLS");
|
||||||
context.init(null, new TrustManager[] { UNTRUSTED_TRUST_MANAGER }, new SecureRandom());
|
context.init(null, new TrustManager[] {UNTRUSTED_TRUST_MANAGER}, new SecureRandom());
|
||||||
SSLSocketFactory sslSocketFactory = context.getSocketFactory();
|
SSLSocketFactory sslSocketFactory = context.getSocketFactory();
|
||||||
SSLSocket socket = (SSLSocket) sslSocketFactory.createSocket(
|
SSLSocket socket = (SSLSocket) sslSocketFactory.createSocket(
|
||||||
raw, raw.getInetAddress().getHostAddress(), raw.getPort(), true);
|
raw, raw.getInetAddress().getHostAddress(), raw.getPort(), true);
|
||||||
@@ -743,9 +733,9 @@ public final class MockWebServer implements TestRule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transfer bytes from {@code source} to {@code sink} until either {@code byteCount}
|
* Transfer bytes from {@code source} to {@code sink} until either {@code byteCount} bytes have
|
||||||
* bytes have been transferred or {@code source} is exhausted. The transfer is
|
* been transferred or {@code source} is exhausted. The transfer is throttled according to {@code
|
||||||
* throttled according to {@code policy}.
|
* policy}.
|
||||||
*/
|
*/
|
||||||
private void throttledTransfer(MockResponse policy, Socket socket, BufferedSource source,
|
private void throttledTransfer(MockResponse policy, Socket socket, BufferedSource source,
|
||||||
BufferedSink sink, long byteCount, boolean isRequest) throws IOException {
|
BufferedSink sink, long byteCount, boolean isRequest) throws IOException {
|
||||||
@@ -801,10 +791,9 @@ public final class MockWebServer implements TestRule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the dispatcher used to match incoming requests to mock responses.
|
* Sets the dispatcher used to match incoming requests to mock responses. The default dispatcher
|
||||||
* The default dispatcher simply serves a fixed sequence of responses from
|
* simply serves a fixed sequence of responses from a {@link #enqueue(MockResponse) queue}; custom
|
||||||
* a {@link #enqueue(MockResponse) queue}; custom dispatchers can vary the
|
* dispatchers can vary the response based on timing or the content of the request.
|
||||||
* response based on timing or the content of the request.
|
|
||||||
*/
|
*/
|
||||||
public void setDispatcher(Dispatcher dispatcher) {
|
public void setDispatcher(Dispatcher dispatcher) {
|
||||||
if (dispatcher == null) throw new NullPointerException();
|
if (dispatcher == null) throw new NullPointerException();
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import java.util.concurrent.LinkedBlockingQueue;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default dispatcher that processes a script of responses. Populate the script
|
* Default dispatcher that processes a script of responses. Populate the script by calling {@link
|
||||||
* by calling {@link #enqueueResponse(MockResponse)}.
|
* #enqueueResponse(MockResponse)}.
|
||||||
*/
|
*/
|
||||||
public class QueueDispatcher extends Dispatcher {
|
public class QueueDispatcher extends Dispatcher {
|
||||||
private static final Logger logger = Logger.getLogger(QueueDispatcher.class.getName());
|
private static final Logger logger = Logger.getLogger(QueueDispatcher.class.getName());
|
||||||
|
|||||||
@@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
package okhttp3.mockwebserver;
|
package okhttp3.mockwebserver;
|
||||||
|
|
||||||
import okhttp3.Headers;
|
|
||||||
import okhttp3.TlsVersion;
|
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.net.ssl.SSLSocket;
|
import javax.net.ssl.SSLSocket;
|
||||||
|
import okhttp3.Headers;
|
||||||
|
import okhttp3.TlsVersion;
|
||||||
import okio.Buffer;
|
import okio.Buffer;
|
||||||
|
|
||||||
/** An HTTP request that came into the mock web server. */
|
/** An HTTP request that came into the mock web server. */
|
||||||
@@ -82,16 +82,15 @@ public final class RecordedRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the sizes of the chunks of this request's body, or an empty list
|
* Returns the sizes of the chunks of this request's body, or an empty list if the request's body
|
||||||
* if the request's body was empty or unchunked.
|
* was empty or unchunked.
|
||||||
*/
|
*/
|
||||||
public List<Integer> getChunkSizes() {
|
public List<Integer> getChunkSizes() {
|
||||||
return chunkSizes;
|
return chunkSizes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the total size of the body of this POST request (before
|
* Returns the total size of the body of this POST request (before truncation).
|
||||||
* truncation).
|
|
||||||
*/
|
*/
|
||||||
public long getBodySize() {
|
public long getBodySize() {
|
||||||
return bodySize;
|
return bodySize;
|
||||||
@@ -108,9 +107,8 @@ public final class RecordedRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the index of this request on its HTTP connection. Since a single
|
* Returns the index of this request on its HTTP connection. Since a single HTTP connection may
|
||||||
* HTTP connection may serve multiple requests, each request is assigned its
|
* serve multiple requests, each request is assigned its own sequence number.
|
||||||
* own sequence number.
|
|
||||||
*/
|
*/
|
||||||
public int getSequenceNumber() {
|
public int getSequenceNumber() {
|
||||||
return sequenceNumber;
|
return sequenceNumber;
|
||||||
|
|||||||
@@ -32,35 +32,32 @@ package okhttp3.mockwebserver;
|
|||||||
public enum SocketPolicy {
|
public enum SocketPolicy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keep the socket open after the response. This is the default HTTP/1.1
|
* Keep the socket open after the response. This is the default HTTP/1.1 behavior.
|
||||||
* behavior.
|
|
||||||
*/
|
*/
|
||||||
KEEP_OPEN,
|
KEEP_OPEN,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the socket after the response. This is the default HTTP/1.0
|
* Close the socket after the response. This is the default HTTP/1.0 behavior.
|
||||||
* behavior.
|
|
||||||
*
|
*
|
||||||
* <p>See {@link SocketPolicy} for reasons why this can cause test flakiness and how to avoid it.
|
* <p>See {@link SocketPolicy} for reasons why this can cause test flakiness and how to avoid it.
|
||||||
*/
|
*/
|
||||||
DISCONNECT_AT_END,
|
DISCONNECT_AT_END,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap the socket with SSL at the completion of this request/response pair.
|
* Wrap the socket with SSL at the completion of this request/response pair. Used for CONNECT
|
||||||
* Used for CONNECT messages to tunnel SSL over an HTTP proxy.
|
* messages to tunnel SSL over an HTTP proxy.
|
||||||
*/
|
*/
|
||||||
UPGRADE_TO_SSL_AT_END,
|
UPGRADE_TO_SSL_AT_END,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request immediate close of connection without even reading the request. Use
|
* Request immediate close of connection without even reading the request. Use to simulate buggy
|
||||||
* to simulate buggy SSL servers closing connections in response to
|
* SSL servers closing connections in response to unrecognized TLS extensions.
|
||||||
* unrecognized TLS extensions.
|
|
||||||
*/
|
*/
|
||||||
DISCONNECT_AT_START,
|
DISCONNECT_AT_START,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close connection after reading the request but before writing the response.
|
* Close connection after reading the request but before writing the response. Use this to
|
||||||
* Use this to simulate late connection pool failures.
|
* simulate late connection pool failures.
|
||||||
*/
|
*/
|
||||||
DISCONNECT_AFTER_REQUEST,
|
DISCONNECT_AFTER_REQUEST,
|
||||||
|
|
||||||
@@ -74,24 +71,22 @@ public enum SocketPolicy {
|
|||||||
FAIL_HANDSHAKE,
|
FAIL_HANDSHAKE,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shutdown the socket input after sending the response. For testing bad
|
* Shutdown the socket input after sending the response. For testing bad behavior.
|
||||||
* behavior.
|
|
||||||
*
|
*
|
||||||
* <p>See {@link SocketPolicy} for reasons why this can cause test flakiness and how to avoid it.
|
* <p>See {@link SocketPolicy} for reasons why this can cause test flakiness and how to avoid it.
|
||||||
*/
|
*/
|
||||||
SHUTDOWN_INPUT_AT_END,
|
SHUTDOWN_INPUT_AT_END,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shutdown the socket output after sending the response. For testing bad
|
* Shutdown the socket output after sending the response. For testing bad behavior.
|
||||||
* behavior.
|
|
||||||
*
|
*
|
||||||
* <p>See {@link SocketPolicy} for reasons why this can cause test flakiness and how to avoid it.
|
* <p>See {@link SocketPolicy} for reasons why this can cause test flakiness and how to avoid it.
|
||||||
*/
|
*/
|
||||||
SHUTDOWN_OUTPUT_AT_END,
|
SHUTDOWN_OUTPUT_AT_END,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Don't respond to the request but keep the socket open. For testing
|
* Don't respond to the request but keep the socket open. For testing read response header timeout
|
||||||
* read response header timeout issue.
|
* issue.
|
||||||
*/
|
*/
|
||||||
NO_RESPONSE
|
NO_RESPONSE
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.mockwebserver;
|
package okhttp3.mockwebserver;
|
||||||
|
|
||||||
import okhttp3.Headers;
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -32,6 +31,7 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import okhttp3.Headers;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -115,8 +115,8 @@ public final class MockWebServerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that MockWebServer blocks for a call to enqueue() if a request
|
* Test that MockWebServer blocks for a call to enqueue() if a request is made before a mock
|
||||||
* is made before a mock response is ready.
|
* response is ready.
|
||||||
*/
|
*/
|
||||||
@Test public void dispatchBlocksWaitingForEnqueue() throws Exception {
|
@Test public void dispatchBlocksWaitingForEnqueue() throws Exception {
|
||||||
new Thread() {
|
new Thread() {
|
||||||
@@ -192,8 +192,8 @@ public final class MockWebServerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throttle the request body by sleeping 500ms after every 3 bytes. With a
|
* Throttle the request body by sleeping 500ms after every 3 bytes. With a 6-byte request, this
|
||||||
* 6-byte request, this should yield one sleep for a total delay of 500ms.
|
* should yield one sleep for a total delay of 500ms.
|
||||||
*/
|
*/
|
||||||
@Test public void throttleRequest() throws Exception {
|
@Test public void throttleRequest() throws Exception {
|
||||||
server.enqueue(new MockResponse()
|
server.enqueue(new MockResponse()
|
||||||
@@ -213,8 +213,8 @@ public final class MockWebServerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throttle the response body by sleeping 500ms after every 3 bytes. With a
|
* Throttle the response body by sleeping 500ms after every 3 bytes. With a 6-byte response, this
|
||||||
* 6-byte response, this should yield one sleep for a total delay of 500ms.
|
* should yield one sleep for a total delay of 500ms.
|
||||||
*/
|
*/
|
||||||
@Test public void throttleResponse() throws Exception {
|
@Test public void throttleResponse() throws Exception {
|
||||||
server.enqueue(new MockResponse()
|
server.enqueue(new MockResponse()
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
|||||||
@@ -15,12 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.sample;
|
package okhttp3.sample;
|
||||||
|
|
||||||
import okhttp3.Cache;
|
|
||||||
import okhttp3.HttpUrl;
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import okhttp3.Request;
|
|
||||||
import okhttp3.Response;
|
|
||||||
import okhttp3.internal.NamedRunnable;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -31,6 +25,12 @@ import java.util.concurrent.ExecutorService;
|
|||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import okhttp3.Cache;
|
||||||
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
import okhttp3.internal.NamedRunnable;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package okhttp3.guide;
|
package okhttp3.guide;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class GetExample {
|
public class GetExample {
|
||||||
OkHttpClient client = new OkHttpClient();
|
OkHttpClient client = new OkHttpClient();
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package okhttp3.guide;
|
package okhttp3.guide;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class PostExample {
|
public class PostExample {
|
||||||
public static final MediaType JSON
|
public static final MediaType JSON
|
||||||
|
|||||||
@@ -15,10 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public final class AccessHeaders {
|
public final class AccessHeaders {
|
||||||
private final OkHttpClient client = new OkHttpClient();
|
private final OkHttpClient client = new OkHttpClient();
|
||||||
|
|||||||
@@ -15,12 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
import okhttp3.Headers;
|
import okhttp3.Headers;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public final class AsynchronousGet {
|
public final class AsynchronousGet {
|
||||||
private final OkHttpClient client = new OkHttpClient();
|
private final OkHttpClient client = new OkHttpClient();
|
||||||
|
|||||||
@@ -15,12 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import okhttp3.Cache;
|
import okhttp3.Cache;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public final class CacheResponse {
|
public final class CacheResponse {
|
||||||
private final OkHttpClient client;
|
private final OkHttpClient client;
|
||||||
|
|||||||
@@ -15,14 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
import okhttp3.Call;
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import okhttp3.Request;
|
|
||||||
import okhttp3.Response;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import okhttp3.Call;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
|
||||||
public class CancelCall {
|
public class CancelCall {
|
||||||
private final ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
|
private final ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
|
||||||
|
|||||||
@@ -15,12 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.security.cert.Certificate;
|
||||||
import okhttp3.CertificatePinner;
|
import okhttp3.CertificatePinner;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import java.io.IOException;
|
|
||||||
import java.security.cert.Certificate;
|
|
||||||
|
|
||||||
public final class CertificatePinning {
|
public final class CertificatePinning {
|
||||||
private final OkHttpClient client;
|
private final OkHttpClient client;
|
||||||
|
|||||||
@@ -15,15 +15,15 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.security.cert.Certificate;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Set;
|
||||||
import okhttp3.CertificatePinner;
|
import okhttp3.CertificatePinner;
|
||||||
import okhttp3.Interceptor;
|
import okhttp3.Interceptor;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import java.io.IOException;
|
|
||||||
import java.security.cert.Certificate;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public final class CheckHandshake {
|
public final class CheckHandshake {
|
||||||
/** Rejects otherwise-trusted certificates. */
|
/** Rejects otherwise-trusted certificates. */
|
||||||
|
|||||||
@@ -15,10 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public final class ConfigureTimeouts {
|
public final class ConfigureTimeouts {
|
||||||
private final OkHttpClient client;
|
private final OkHttpClient client;
|
||||||
|
|||||||
@@ -15,11 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
import okhttp3.CertificatePinner;
|
|
||||||
import okhttp3.Headers;
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import okhttp3.Request;
|
|
||||||
import okhttp3.Response;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
@@ -31,6 +26,11 @@ import java.util.Collection;
|
|||||||
import javax.net.ssl.KeyManagerFactory;
|
import javax.net.ssl.KeyManagerFactory;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.TrustManagerFactory;
|
import javax.net.ssl.TrustManagerFactory;
|
||||||
|
import okhttp3.CertificatePinner;
|
||||||
|
import okhttp3.Headers;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
import okio.Buffer;
|
import okio.Buffer;
|
||||||
|
|
||||||
public final class CustomTrust {
|
public final class CustomTrust {
|
||||||
@@ -150,8 +150,9 @@ public final class CustomTrust {
|
|||||||
* the host platform's built-in trust store.
|
* the host platform's built-in trust store.
|
||||||
*
|
*
|
||||||
* <h3>Warning: Customizing Trusted Certificates is Dangerous!</h3>
|
* <h3>Warning: Customizing Trusted Certificates is Dangerous!</h3>
|
||||||
* Relying on your own trusted certificates limits your server team's ability to update their TLS
|
*
|
||||||
* certificates. By installing a specific set of trusted certificates, you take on additional
|
* <p>Relying on your own trusted certificates limits your server team's ability to update their
|
||||||
|
* TLS certificates. By installing a specific set of trusted certificates, you take on additional
|
||||||
* operational complexity and limit your ability to migrate between certificate authorities. Do
|
* operational complexity and limit your ability to migrate between certificate authorities. Do
|
||||||
* not use custom trusted certificates in production without the blessing of your server's TLS
|
* not use custom trusted certificates in production without the blessing of your server's TLS
|
||||||
* administrator.
|
* administrator.
|
||||||
|
|||||||
@@ -15,12 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import okhttp3.Interceptor;
|
import okhttp3.Interceptor;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public final class LoggingInterceptors {
|
public final class LoggingInterceptors {
|
||||||
private static final Logger logger = Logger.getLogger(LoggingInterceptors.class.getName());
|
private static final Logger logger = Logger.getLogger(LoggingInterceptors.class.getName());
|
||||||
|
|||||||
@@ -16,11 +16,11 @@
|
|||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public final class ParseResponseWithGson {
|
public final class ParseResponseWithGson {
|
||||||
private final OkHttpClient client = new OkHttpClient();
|
private final OkHttpClient client = new OkHttpClient();
|
||||||
|
|||||||
@@ -15,11 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public final class PerCallSettings {
|
public final class PerCallSettings {
|
||||||
private final OkHttpClient client = new OkHttpClient();
|
private final OkHttpClient client = new OkHttpClient();
|
||||||
|
|||||||
@@ -15,13 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public final class PostFile {
|
public final class PostFile {
|
||||||
public static final MediaType MEDIA_TYPE_MARKDOWN
|
public static final MediaType MEDIA_TYPE_MARKDOWN
|
||||||
|
|||||||
@@ -15,12 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import okhttp3.FormBody;
|
import okhttp3.FormBody;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public final class PostForm {
|
public final class PostForm {
|
||||||
private final OkHttpClient client = new OkHttpClient();
|
private final OkHttpClient client = new OkHttpClient();
|
||||||
|
|||||||
@@ -15,20 +15,19 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
import okhttp3.MultipartBody;
|
import okhttp3.MultipartBody;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public final class PostMultipart {
|
public final class PostMultipart {
|
||||||
/**
|
/**
|
||||||
* The imgur client ID for OkHttp recipes. If you're using imgur for anything
|
* The imgur client ID for OkHttp recipes. If you're using imgur for anything other than running
|
||||||
* other than running these examples, please request your own client ID!
|
* these examples, please request your own client ID! https://api.imgur.com/oauth2
|
||||||
* https://api.imgur.com/oauth2
|
|
||||||
*/
|
*/
|
||||||
private static final String IMGUR_CLIENT_ID = "9199fdef135c122";
|
private static final String IMGUR_CLIENT_ID = "9199fdef135c122";
|
||||||
private static final MediaType MEDIA_TYPE_PNG = MediaType.parse("image/png");
|
private static final MediaType MEDIA_TYPE_PNG = MediaType.parse("image/png");
|
||||||
|
|||||||
@@ -15,12 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import java.io.IOException;
|
|
||||||
import okio.BufferedSink;
|
import okio.BufferedSink;
|
||||||
|
|
||||||
public final class PostStreaming {
|
public final class PostStreaming {
|
||||||
|
|||||||
@@ -15,12 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public final class PostString {
|
public final class PostString {
|
||||||
public static final MediaType MEDIA_TYPE_MARKDOWN
|
public static final MediaType MEDIA_TYPE_MARKDOWN
|
||||||
|
|||||||
@@ -15,13 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import okhttp3.Interceptor;
|
import okhttp3.Interceptor;
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
import okhttp3.Request;
|
|
||||||
import java.io.IOException;
|
|
||||||
import okio.Buffer;
|
import okio.Buffer;
|
||||||
import okio.BufferedSource;
|
import okio.BufferedSource;
|
||||||
import okio.ForwardingSource;
|
import okio.ForwardingSource;
|
||||||
@@ -94,6 +94,7 @@ public final class Progress {
|
|||||||
private Source source(Source source) {
|
private Source source(Source source) {
|
||||||
return new ForwardingSource(source) {
|
return new ForwardingSource(source) {
|
||||||
long totalBytesRead = 0L;
|
long totalBytesRead = 0L;
|
||||||
|
|
||||||
@Override public long read(Buffer sink, long byteCount) throws IOException {
|
@Override public long read(Buffer sink, long byteCount) throws IOException {
|
||||||
long bytesRead = super.read(sink, byteCount);
|
long bytesRead = super.read(sink, byteCount);
|
||||||
// read() returns the number of bytes read, or -1 if this source is exhausted.
|
// read() returns the number of bytes read, or -1 if this source is exhausted.
|
||||||
|
|||||||
@@ -16,15 +16,15 @@
|
|||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
import okhttp3.Interceptor;
|
import okhttp3.Interceptor;
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import okio.BufferedSink;
|
import okio.BufferedSink;
|
||||||
import okio.GzipSink;
|
import okio.GzipSink;
|
||||||
import okio.Okio;
|
import okio.Okio;
|
||||||
@@ -33,6 +33,7 @@ public final class RequestBodyCompression {
|
|||||||
/**
|
/**
|
||||||
* The Google API KEY for OkHttp recipes. If you're using Google APIs for anything other than
|
* The Google API KEY for OkHttp recipes. If you're using Google APIs for anything other than
|
||||||
* running these examples, please request your own client ID!
|
* running these examples, please request your own client ID!
|
||||||
|
*
|
||||||
* https://console.developers.google.com/project
|
* https://console.developers.google.com/project
|
||||||
*/
|
*/
|
||||||
public static final String GOOGLE_API_KEY = "AIzaSyAx2WZYe0My0i-uGurpvraYJxO7XNbwiGs";
|
public static final String GOOGLE_API_KEY = "AIzaSyAx2WZYe0My0i-uGurpvraYJxO7XNbwiGs";
|
||||||
|
|||||||
@@ -15,13 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import okhttp3.Cache;
|
import okhttp3.Cache;
|
||||||
import okhttp3.Interceptor;
|
import okhttp3.Interceptor;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public final class RewriteResponseCacheControl {
|
public final class RewriteResponseCacheControl {
|
||||||
/** Dangerous interceptor that rewrites the server's cache-control header. */
|
/** Dangerous interceptor that rewrites the server's cache-control header. */
|
||||||
|
|||||||
@@ -15,11 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import okhttp3.Headers;
|
import okhttp3.Headers;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public final class SynchronousGet {
|
public final class SynchronousGet {
|
||||||
private final OkHttpClient client = new OkHttpClient();
|
private final OkHttpClient client = new OkHttpClient();
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
@@ -8,9 +11,6 @@ import okhttp3.ResponseBody;
|
|||||||
import okhttp3.ws.WebSocket;
|
import okhttp3.ws.WebSocket;
|
||||||
import okhttp3.ws.WebSocketCall;
|
import okhttp3.ws.WebSocketCall;
|
||||||
import okhttp3.ws.WebSocketListener;
|
import okhttp3.ws.WebSocketListener;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import okio.Buffer;
|
import okio.Buffer;
|
||||||
import okio.ByteString;
|
import okio.ByteString;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ package okhttp3.sample;
|
|||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import okhttp3.Request;
|
|
||||||
import okhttp3.Response;
|
|
||||||
import okhttp3.ResponseBody;
|
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
import okhttp3.ResponseBody;
|
||||||
|
|
||||||
public class OkHttpContributors {
|
public class OkHttpContributors {
|
||||||
private static final String ENDPOINT = "https://api.github.com/repos/square/okhttp/contributors";
|
private static final String ENDPOINT = "https://api.github.com/repos/square/okhttp/contributors";
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
@@ -31,7 +33,8 @@
|
|||||||
<shadedArtifactAttached>true</shadedArtifactAttached>
|
<shadedArtifactAttached>true</shadedArtifactAttached>
|
||||||
<shadedClassifierName>shaded</shadedClassifierName>
|
<shadedClassifierName>shaded</shadedClassifierName>
|
||||||
<transformers>
|
<transformers>
|
||||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
<transformer
|
||||||
|
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||||
<manifestEntries>
|
<manifestEntries>
|
||||||
<Main-Class>okhttp3.sample.SampleServer</Main-Class>
|
<Main-Class>okhttp3.sample.SampleServer</Main-Class>
|
||||||
</manifestEntries>
|
</manifestEntries>
|
||||||
@@ -51,7 +54,9 @@
|
|||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
<goals><goal>shade</goal></goals>
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
package okhttp3.sample;
|
package okhttp3.sample;
|
||||||
|
|
||||||
import okhttp3.internal.Util;
|
|
||||||
import okhttp3.mockwebserver.Dispatcher;
|
|
||||||
import okhttp3.mockwebserver.MockResponse;
|
|
||||||
import okhttp3.mockwebserver.MockWebServer;
|
|
||||||
import okhttp3.mockwebserver.RecordedRequest;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@@ -16,6 +11,11 @@ import java.security.SecureRandom;
|
|||||||
import javax.net.ssl.KeyManagerFactory;
|
import javax.net.ssl.KeyManagerFactory;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.TrustManagerFactory;
|
import javax.net.ssl.TrustManagerFactory;
|
||||||
|
import okhttp3.internal.Util;
|
||||||
|
import okhttp3.mockwebserver.Dispatcher;
|
||||||
|
import okhttp3.mockwebserver.MockResponse;
|
||||||
|
import okhttp3.mockwebserver.MockWebServer;
|
||||||
|
import okhttp3.mockwebserver.RecordedRequest;
|
||||||
import okio.Buffer;
|
import okio.Buffer;
|
||||||
import okio.Okio;
|
import okio.Okio;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user