Skip to content

Commits on Source 8

......@@ -2,6 +2,7 @@ language: java
jdk:
- oraclejdk8
# - openjdk11
addons:
apt:
......
Change Log
==========
## Version 3.12.0
_2018-11-16_
* **OkHttp now supports TLS 1.3.** This requires either Conscrypt or Java 11+.
* **Proxy authenticators are now asked for preemptive authentication.** OkHttp will now request
authentication credentials before creating TLS tunnels through HTTP proxies (HTTP `CONNECT`).
Authenticators should identify preemptive authentications by the presence of a challenge whose
scheme is "OkHttp-Preemptive".
* **OkHttp now offers full-operation timeouts.** This sets a limit on how long the entire call may
take and covers resolving DNS, connecting, writing the request body, server processing, and
reading the full response body. If a call requires redirects or retries all must complete within
one timeout period.
Use `OkHttpClient.Builder.callTimeout()` to specify the default duration and `Call.timeout()` to
specify the timeout of an individual call.
* New: Return values and fields are now non-null unless otherwise annotated.
* New: `LoggingEventListener` makes it easy to get basic visibility into a call's performance.
This class is in the `logging-interceptor` artifact.
* New: `Headers.Builder.addUnsafeNonAscii()` allows non-ASCII values to be added without an
immediate exception.
* New: Headers can be redacted in `HttpLoggingInterceptor`.
* New: `Headers.Builder` now accepts dates.
* New: OkHttp now accepts `java.time.Duration` for timeouts on Java 8+ and Android 26+.
* New: `Challenge` includes all authentication parameters.
* New: Upgrade to BouncyCastle 1.60, Conscrypt 1.4.0, and Okio 1.15.0. We don't yet require
Kotlin-friendly Okio 2.x but OkHttp works fine with that series.
```kotlin
implementation("org.bouncycastle:bcprov-jdk15on:1.60")
implementation("org.conscrypt:conscrypt-openjdk-uber:1.4.0")
implementation("com.squareup.okio:okio:1.15.0")
```
* Fix: Handle dispatcher executor shutdowns gracefully. When there aren't any threads to carry a
call its callback now gets a `RejectedExecutionException`.
* Fix: Don't permanently cache responses with `Cache-Control: immutable`. We misunderstood the
original `immutable` proposal!
* Fix: Change `Authenticator`'s `Route` parameter to be nullable. This was marked as non-null but
could be called with null in some cases.
* Fix: Don't create malformed URLs when `MockWebServer` is reached via an IPv6 address.
* Fix: Don't crash if the system default authenticator is null.
* Fix: Don't crash generating elliptic curve certificates on Android.
* Fix: Don't crash doing platform detection on RoboVM.
* Fix: Don't leak socket connections when web socket upgrades fail.
## Version 3.11.0
_2018-07-12_
......
......@@ -6,17 +6,10 @@ An HTTP & HTTP/2 client for Android and Java applications. For more information
Download
--------
Download [the latest JAR][3] or grab via Maven:
```xml
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.10.0</version>
</dependency>
```
or Gradle:
```groovy
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
Download [the latest JAR][3] or configure this dependency:
```kotlin
implementation("com.squareup.okhttp3:okhttp:3.12.0")
```
Snapshots of the development version are available in [Sonatype's `snapshots` repository][snap].
......@@ -31,18 +24,9 @@ MockWebServer coupling with OkHttp is essential for proper testing of HTTP/2 so
### Download
Download [the latest JAR][4] or grab via Maven:
Download [the latest JAR][4] or configure this dependency:
```xml
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<version>3.10.0</version>
<scope>test</scope>
</dependency>
```
or Gradle:
```groovy
testImplementation 'com.squareup.okhttp3:mockwebserver:3.10.0'
testImplementation("com.squareup.okhttp3:mockwebserver:3.12.0")
```
R8 / ProGuard
......
......@@ -6,7 +6,7 @@
<parent>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>parent</artifactId>
<version>3.11.0</version>
<version>3.12.0</version>
</parent>
<artifactId>benchmarks</artifactId>
......
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>parent</artifactId>
<version>3.12.0</version>
</parent>
<artifactId>okhttp-bom</artifactId>
<packaging>pom</packaging>
<name>OkHttp (Bill of Materials)</name>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>okhttp</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>okhttp-tests</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>okhttp-android-support</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>okhttp-apache</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>okhttp-sse</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>okhttp-testing-support</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>okhttp-tls</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>okhttp-urlconnection</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>okhttp-logging-interceptor</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>okhttp-dnsoverhttps</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>okcurl</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mockwebserver</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
libokhttp-java (3.12.0-1) unstable; urgency=medium
* New upstream version 3.12.0.
* Remove get-orig-source target.
* Declare compliance with Debian Policy 4.2.1.
* Build-depend on libanimal-sniffer-java.
-- Markus Koschany <apo@debian.org> Fri, 14 Dec 2018 21:45:40 +0000
libokhttp-java (3.11.0-1) unstable; urgency=medium
* New upstream version 3.11.0.
......
......@@ -10,9 +10,10 @@ Build-Depends:
default-jdk,
javahelper,
libandroid-23-java,
libanimal-sniffer-java,
libokio-java (>= 1.14.0),
maven-debian-helper (>= 2.1)
Standards-Version: 4.1.5
Standards-Version: 4.2.1
Vcs-Git: https://anonscm.debian.org/git/pkg-java/libokhttp-java.git
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-java/libokhttp-java.git
Homepage: https://github.com/square/okhttp
......
From: Markus Koschany <apo@debian.org>
Date: Fri, 27 Jul 2018 19:22:11 +0200
Date: Fri, 14 Dec 2018 21:48:22 +0000
Subject: no Conscrypt
---
.../internal/platform/ConscryptPlatform.java | 118 ---------------------
.../internal/platform/ConscryptPlatform.java | 122 ---------------------
.../java/okhttp3/internal/platform/Platform.java | 2 +-
2 files changed, 1 insertion(+), 119 deletions(-)
2 files changed, 1 insertion(+), 123 deletions(-)
delete mode 100644 okhttp/src/main/java/okhttp3/internal/platform/ConscryptPlatform.java
diff --git a/okhttp/src/main/java/okhttp3/internal/platform/ConscryptPlatform.java b/okhttp/src/main/java/okhttp3/internal/platform/ConscryptPlatform.java
deleted file mode 100644
index 9ed9b1d..0000000
index e460595..0000000
--- a/okhttp/src/main/java/okhttp3/internal/platform/ConscryptPlatform.java
+++ /dev/null
@@ -1,118 +0,0 @@
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2014 Square, Inc.
- *
......@@ -41,7 +41,6 @@ index 9ed9b1d..0000000
-import javax.net.ssl.X509TrustManager;
-import okhttp3.Protocol;
-import org.conscrypt.Conscrypt;
-import org.conscrypt.OpenSSLProvider;
-
-/**
- * Platform using Conscrypt (conscrypt.org) if installed as the first Security Provider.
......@@ -53,10 +52,10 @@ index 9ed9b1d..0000000
- }
-
- private Provider getProvider() {
- return new OpenSSLProvider();
- return Conscrypt.newProviderBuilder().provideTrustManager().build();
- }
-
- @Override public X509TrustManager trustManager(SSLSocketFactory sslSocketFactory) {
- @Override public @Nullable X509TrustManager trustManager(SSLSocketFactory sslSocketFactory) {
- if (!Conscrypt.isConscrypt(sslSocketFactory)) {
- return super.trustManager(sslSocketFactory);
- }
......@@ -104,16 +103,21 @@ index 9ed9b1d..0000000
-
- @Override public SSLContext getSSLContext() {
- try {
- return SSLContext.getInstance("TLS", getProvider());
- return SSLContext.getInstance("TLSv1.3", getProvider());
- } catch (NoSuchAlgorithmException e) {
- try {
- // Allow for Conscrypt 1.2
- return SSLContext.getInstance("TLS", getProvider());
- } catch (NoSuchAlgorithmException e2) {
- throw new IllegalStateException("No TLS provider", e);
- }
- }
- }
-
- public static Platform buildIfSupported() {
- public static ConscryptPlatform buildIfSupported() {
- try {
- // trigger early exception over a fatal error
- Class.forName("org.conscrypt.ConscryptEngineSocket");
- // Trigger an early exception over a fatal error, prefer a RuntimeException over Error.
- Class.forName("org.conscrypt.Conscrypt");
-
- if (!Conscrypt.isAvailable()) {
- return null;
......@@ -133,7 +137,7 @@ index 9ed9b1d..0000000
- }
-}
diff --git a/okhttp/src/main/java/okhttp3/internal/platform/Platform.java b/okhttp/src/main/java/okhttp3/internal/platform/Platform.java
index 4803359..8a63b47 100644
index ac15233..95ff341 100644
--- a/okhttp/src/main/java/okhttp3/internal/platform/Platform.java
+++ b/okhttp/src/main/java/okhttp3/internal/platform/Platform.java
@@ -205,7 +205,7 @@ public class Platform {
......
......@@ -7,10 +7,10 @@ Subject: no javac with errorprone
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 956fb3b..0907917 100644
index 14a31f6..91fea74 100644
--- a/pom.xml
+++ b/pom.xml
@@ -153,7 +153,7 @@
@@ -154,7 +154,7 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
......
......@@ -13,5 +13,3 @@ override_dh_auto_build:
$(CURDIR)/okhttp/src/main/java/okhttp3/internal/Version.java
dh_auto_build
get-orig-source:
uscan --download-current-version --force-download --repack --compression xz
......@@ -6,7 +6,7 @@
<parent>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>parent</artifactId>
<version>3.11.0</version>
<version>3.12.0</version>
</parent>
<artifactId>mockwebserver</artifactId>
......
......@@ -90,6 +90,7 @@ import static okhttp3.mockwebserver.SocketPolicy.NO_RESPONSE;
import static okhttp3.mockwebserver.SocketPolicy.RESET_STREAM_AT_START;
import static okhttp3.mockwebserver.SocketPolicy.SHUTDOWN_INPUT_AT_END;
import static okhttp3.mockwebserver.SocketPolicy.SHUTDOWN_OUTPUT_AT_END;
import static okhttp3.mockwebserver.SocketPolicy.SHUTDOWN_SERVER_AFTER_RESPONSE;
import static okhttp3.mockwebserver.SocketPolicy.STALL_SOCKET_AT_START;
import static okhttp3.mockwebserver.SocketPolicy.UPGRADE_TO_SSL_AT_END;
......@@ -589,6 +590,8 @@ public final class MockWebServer extends ExternalResource implements Closeable {
socket.shutdownInput();
} else if (response.getSocketPolicy() == SHUTDOWN_OUTPUT_AT_END) {
socket.shutdownOutput();
} else if (response.getSocketPolicy() == SHUTDOWN_SERVER_AFTER_RESPONSE) {
shutdown();
}
sequenceNumber++;
......@@ -934,24 +937,24 @@ public final class MockWebServer extends ExternalResource implements Closeable {
}
private RecordedRequest readRequest(Http2Stream stream) throws IOException {
List<Header> streamHeaders = stream.getRequestHeaders();
Headers streamHeaders = stream.takeHeaders();
Headers.Builder httpHeaders = new Headers.Builder();
String method = "<:method omitted>";
String path = "<:path omitted>";
boolean readBody = true;
for (int i = 0, size = streamHeaders.size(); i < size; i++) {
ByteString name = streamHeaders.get(i).name;
String value = streamHeaders.get(i).value.utf8();
if (name.equals(Header.TARGET_METHOD)) {
String name = streamHeaders.name(i);
String value = streamHeaders.value(i);
if (name.equals(Header.TARGET_METHOD_UTF8)) {
method = value;
} else if (name.equals(Header.TARGET_PATH)) {
} else if (name.equals(Header.TARGET_PATH_UTF8)) {
path = value;
} else if (protocol == Protocol.HTTP_2 || protocol == Protocol.H2_PRIOR_KNOWLEDGE) {
httpHeaders.add(name.utf8(), value);
httpHeaders.add(name, value);
} else {
throw new IllegalStateException();
}
if (name.utf8().equals("expect") && value.equalsIgnoreCase("100-continue")) {
if (name.equals("expect") && value.equalsIgnoreCase("100-continue")) {
// Don't read the body unless we've invited the client to send it.
readBody = false;
}
......@@ -960,7 +963,7 @@ public final class MockWebServer extends ExternalResource implements Closeable {
MockResponse peek = dispatcher.peek();
if (!readBody && peek.getSocketPolicy() == EXPECT_CONTINUE) {
stream.sendResponseHeaders(Collections.singletonList(
stream.writeHeaders(Collections.singletonList(
new Header(Header.RESPONSE_STATUS, ByteString.encodeUtf8("100 Continue"))), true);
stream.getConnection().flush();
readBody = true;
......@@ -1006,7 +1009,7 @@ public final class MockWebServer extends ExternalResource implements Closeable {
Buffer body = response.getBody();
boolean closeStreamAfterHeaders = body != null || !response.getPushPromises().isEmpty();
stream.sendResponseHeaders(http2Headers, closeStreamAfterHeaders);
stream.writeHeaders(http2Headers, closeStreamAfterHeaders);
pushPromises(stream, response.getPushPromises());
if (body != null) {
BufferedSink sink = Okio.buffer(stream.getSink());
......
......@@ -17,6 +17,8 @@
package okhttp3.mockwebserver;
import java.io.IOException;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.Socket;
import java.util.List;
import javax.net.ssl.SSLSocket;
......@@ -61,12 +63,24 @@ public final class RecordedRequest {
int methodEnd = requestLine.indexOf(' ');
int pathEnd = requestLine.indexOf(' ', methodEnd + 1);
this.method = requestLine.substring(0, methodEnd);
this.path = requestLine.substring(methodEnd + 1, pathEnd);
String path = requestLine.substring(methodEnd + 1, pathEnd);
if (!path.startsWith("/")) {
path = "/";
}
this.path = path;
String scheme = socket instanceof SSLSocket ? "https" : "http";
String hostname = socket.getInetAddress().getHostName();
int port = socket.getLocalPort();
this.requestUrl = HttpUrl.parse(String.format("%s://%s:%s%s", scheme, hostname, port, path));
InetAddress inetAddress = socket.getLocalAddress();
String hostname = inetAddress.getHostName();
if (inetAddress instanceof Inet6Address) {
hostname = "[" + hostname + "]";
}
int localPort = socket.getLocalPort();
// Allow null in failure case to allow for testing bad requests
this.requestUrl =
HttpUrl.parse(String.format("%s://%s:%s%s", scheme, hostname, localPort, path));
} else {
this.requestUrl = null;
this.method = null;
......
......@@ -31,6 +31,11 @@ package okhttp3.mockwebserver;
*/
public enum SocketPolicy {
/**
* Shutdown {@link MockWebServer} after writing response.
*/
SHUTDOWN_SERVER_AFTER_RESPONSE,
/**
* Keep the socket open after the response. This is the default HTTP/1.1 behavior.
*/
......
......@@ -452,6 +452,24 @@ public final class MockWebServerTest {
assertEquals("foo bar", requestUrl.queryParameter("key"));
}
@Test public void shutdownServerAfterRequest() throws Exception {
server.enqueue(new MockResponse().setSocketPolicy(SocketPolicy.SHUTDOWN_SERVER_AFTER_RESPONSE));
URL url = server.url("/").url();
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
HttpURLConnection refusedConnection = (HttpURLConnection) url.openConnection();
try {
refusedConnection.getResponseCode();
fail("Second connection should be refused");
} catch (ConnectException e ) {
assertTrue(e.getMessage().contains("refused"));
}
}
@Test public void http100Continue() throws Exception {
server.enqueue(new MockResponse().setBody("response"));
......
/*
* Copyright (C) 2012 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package okhttp3.mockwebserver;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Collections;
import java.util.Random;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okio.Buffer;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class RecordedRequestTest {
Headers headers = new Headers.Builder().build();
private class FakeSocket extends Socket {
private final InetAddress localAddress;
private final int remotePort;
private final InetAddress remoteAddress;
private final int localPort;
private FakeSocket(int localPort) {
this(Inet4Address.getLoopbackAddress(), localPort);
}
private FakeSocket(InetAddress inetAddress, int localPort) {
this(inetAddress, localPort, inetAddress, 1234);
}
private FakeSocket(InetAddress localAddress, int localPort, InetAddress remoteAddress, int remotePort) {
this.localAddress = localAddress;
this.localPort = localPort;
this.remoteAddress = remoteAddress;
this.remotePort = remotePort;
}
@Override public InetAddress getInetAddress() {
return remoteAddress;
}
@Override public InetAddress getLocalAddress() {
return localAddress;
}
@Override public int getLocalPort() {
return localPort;
}
@Override public int getPort() {
return remotePort;
}
}
@Test public void testIPv4() throws UnknownHostException {
Socket socket =
new FakeSocket(InetAddress.getByAddress("127.0.0.1", new byte[] { 127, 0, 0, 1 }), 80);
RecordedRequest request =
new RecordedRequest("GET / HTTP/1.1", headers, Collections.<Integer>emptyList(), 0,
new Buffer(), 0, socket);
assertEquals("http://127.0.0.1/", request.getRequestUrl().toString());
}
@Test public void testIPv6() throws UnknownHostException {
Socket socket = new FakeSocket(InetAddress.getByAddress("::1",
new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }), 80);
RecordedRequest request =
new RecordedRequest("GET / HTTP/1.1", headers, Collections.<Integer>emptyList(), 0,
new Buffer(), 0, socket);
assertEquals("http://[::1]/", request.getRequestUrl().toString());
}
@Test public void testUsesLocal() throws UnknownHostException {
Socket socket =
new FakeSocket(InetAddress.getByAddress("127.0.0.1", new byte[] { 127, 0, 0, 1 }), 80);
RecordedRequest request =
new RecordedRequest("GET / HTTP/1.1", headers, Collections.<Integer>emptyList(), 0,
new Buffer(), 0, socket);
assertEquals("http://127.0.0.1/", request.getRequestUrl().toString());
}
}
......@@ -28,6 +28,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import okhttp3.Headers;
import okhttp3.Protocol;
import okhttp3.internal.Util;
import okhttp3.internal.http2.Header;
......@@ -95,11 +96,11 @@ public final class Http2Server extends Http2Connection.Listener {
@Override public void onStream(Http2Stream stream) throws IOException {
try {
List<Header> requestHeaders = stream.getRequestHeaders();
Headers requestHeaders = stream.takeHeaders();
String path = null;
for (int i = 0, size = requestHeaders.size(); i < size; i++) {
if (requestHeaders.get(i).name.equals(Header.TARGET_PATH)) {
path = requestHeaders.get(i).value.utf8();
if (requestHeaders.name(i).equals(Header.TARGET_PATH_UTF8)) {
path = requestHeaders.value(i);
break;
}
}
......@@ -129,7 +130,7 @@ public final class Http2Server extends Http2Connection.Listener {
new Header(":version", "HTTP/1.1"),
new Header("content-type", "text/plain")
);
stream.sendResponseHeaders(responseHeaders, true);
stream.writeHeaders(responseHeaders, true);
BufferedSink out = Okio.buffer(stream.getSink());
out.writeUtf8("Not found: " + path);
out.close();
......@@ -141,7 +142,7 @@ public final class Http2Server extends Http2Connection.Listener {
new Header(":version", "HTTP/1.1"),
new Header("content-type", "text/html; charset=UTF-8")
);
stream.sendResponseHeaders(responseHeaders, true);
stream.writeHeaders(responseHeaders, true);
BufferedSink out = Okio.buffer(stream.getSink());
for (File file : files) {
String target = file.isDirectory() ? (file.getName() + "/") : file.getName();
......@@ -156,7 +157,7 @@ public final class Http2Server extends Http2Connection.Listener {
new Header(":version", "HTTP/1.1"),
new Header("content-type", contentType(file))
);
stream.sendResponseHeaders(responseHeaders, true);
stream.writeHeaders(responseHeaders, true);
Source source = Okio.source(file);
try {
BufferedSink out = Okio.buffer(stream.getSink());
......
......@@ -6,7 +6,7 @@
<parent>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>parent</artifactId>
<version>3.11.0</version>
<version>3.12.0</version>
</parent>
<artifactId>okcurl</artifactId>
......@@ -18,6 +18,11 @@
<artifactId>okhttp</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>logging-interceptor</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>okhttp-testing-support</artifactId>
......
......@@ -48,6 +48,8 @@ import okhttp3.internal.Util;
import okhttp3.internal.http.StatusLine;
import okhttp3.internal.http2.Http2;
import okhttp3.internal.platform.Platform;
import okhttp3.logging.HttpLoggingInterceptor;
import okhttp3.logging.LoggingEventListener;
import okio.BufferedSource;
import okio.Okio;
import okio.Sink;
......@@ -121,6 +123,11 @@ public class Main extends HelpOption implements Runnable {
@Option(name = {"-V", "--version"}, description = "Show version number and quit")
public boolean version;
@Option(
name = {"-v", "--verbose"},
description = "Makes " + NAME + " verbose during the operation")
public boolean verbose;
@Arguments(title = "url", description = "Remote resource URL")
public String url;
......@@ -184,6 +191,16 @@ public class Main extends HelpOption implements Runnable {
builder.sslSocketFactory(sslSocketFactory, trustManager);
builder.hostnameVerifier(createInsecureHostnameVerifier());
}
if (verbose) {
HttpLoggingInterceptor.Logger logger =
new HttpLoggingInterceptor.Logger() {
@Override
public void log(String message) {
System.out.println(message);
}
};
builder.eventListenerFactory(new LoggingEventListener.Factory(logger));
}
return builder.build();
}
......
......@@ -6,7 +6,7 @@
<parent>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>parent</artifactId>
<version>3.11.0</version>
<version>3.12.0</version>
</parent>
<artifactId>okhttp-android-support</artifactId>
......