diff --git a/mockwebserver/src/main/java/okhttp3/internal/framed/FramedServer.java b/mockwebserver/src/main/java/okhttp3/internal/framed/FramedServer.java index 2a555be68..9dc3c502e 100644 --- a/mockwebserver/src/main/java/okhttp3/internal/framed/FramedServer.java +++ b/mockwebserver/src/main/java/okhttp3/internal/framed/FramedServer.java @@ -28,14 +28,14 @@ import java.util.logging.Logger; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import okhttp3.Protocol; -import okhttp3.internal.Platform; import okhttp3.internal.Util; +import okhttp3.internal.platform.Platform; import okhttp3.internal.tls.SslClient; import okio.BufferedSink; import okio.Okio; import okio.Source; -import static okhttp3.internal.Platform.INFO; +import static okhttp3.internal.platform.Platform.INFO; /** A basic SPDY/HTTP_2 server that serves the contents of a local directory. */ public final class FramedServer extends FramedConnection.Listener { diff --git a/mockwebserver/src/main/java/okhttp3/mockwebserver/MockWebServer.java b/mockwebserver/src/main/java/okhttp3/mockwebserver/MockWebServer.java index 89df44253..180e03bb1 100644 --- a/mockwebserver/src/main/java/okhttp3/mockwebserver/MockWebServer.java +++ b/mockwebserver/src/main/java/okhttp3/mockwebserver/MockWebServer.java @@ -59,7 +59,6 @@ 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; @@ -67,6 +66,7 @@ import okhttp3.internal.framed.FramedStream; import okhttp3.internal.framed.Header; import okhttp3.internal.framed.Settings; import okhttp3.internal.http.HttpMethod; +import okhttp3.internal.platform.Platform; import okhttp3.internal.ws.RealWebSocket; import okhttp3.internal.ws.WebSocketProtocol; import okhttp3.ws.WebSocketListener; diff --git a/okhttp-android-support/src/main/java/okhttp3/AndroidShimResponseCache.java b/okhttp-android-support/src/main/java/okhttp3/AndroidShimResponseCache.java index b0bb9fcf7..c46a0cb9f 100644 --- a/okhttp-android-support/src/main/java/okhttp3/AndroidShimResponseCache.java +++ b/okhttp-android-support/src/main/java/okhttp3/AndroidShimResponseCache.java @@ -70,7 +70,7 @@ public class AndroidShimResponseCache extends ResponseCache { // The URLConnection is not cacheable or could not be converted. Stop. return null; } - okhttp3.internal.http.CacheRequest okCacheRequest = + okhttp3.internal.cache.CacheRequest okCacheRequest = delegate.internalCache.put(okResponse); if (okCacheRequest == null) { return null; diff --git a/okhttp-android-support/src/main/java/okhttp3/internal/huc/CacheAdapter.java b/okhttp-android-support/src/main/java/okhttp3/internal/huc/CacheAdapter.java index 8e02239de..65d6197fc 100644 --- a/okhttp-android-support/src/main/java/okhttp3/internal/huc/CacheAdapter.java +++ b/okhttp-android-support/src/main/java/okhttp3/internal/huc/CacheAdapter.java @@ -25,9 +25,9 @@ import java.util.List; import java.util.Map; import okhttp3.Request; import okhttp3.Response; -import okhttp3.internal.InternalCache; -import okhttp3.internal.http.CacheRequest; -import okhttp3.internal.http.CacheStrategy; +import okhttp3.internal.cache.CacheRequest; +import okhttp3.internal.cache.CacheStrategy; +import okhttp3.internal.cache.InternalCache; import okio.Okio; import okio.Sink; diff --git a/okhttp-android-support/src/main/java/okhttp3/internal/huc/JavaApiConverter.java b/okhttp-android-support/src/main/java/okhttp3/internal/huc/JavaApiConverter.java index d43645564..be502113f 100644 --- a/okhttp-android-support/src/main/java/okhttp3/internal/huc/JavaApiConverter.java +++ b/okhttp-android-support/src/main/java/okhttp3/internal/huc/JavaApiConverter.java @@ -44,12 +44,12 @@ import okhttp3.Response; import okhttp3.ResponseBody; import okhttp3.internal.Internal; import okhttp3.internal.JavaNetHeaders; -import okhttp3.internal.Platform; import okhttp3.internal.Util; -import okhttp3.internal.http.CacheRequest; +import okhttp3.internal.cache.CacheRequest; +import okhttp3.internal.http.HttpHeaders; import okhttp3.internal.http.HttpMethod; -import okhttp3.internal.http.OkHeaders; import okhttp3.internal.http.StatusLine; +import okhttp3.internal.platform.Platform; import okio.BufferedSource; import okio.Okio; import okio.Sink; @@ -162,11 +162,11 @@ public final class JavaApiConverter { } private static Headers varyHeaders(URLConnection urlConnection, Headers responseHeaders) { - if (OkHeaders.hasVaryAll(responseHeaders)) { + if (HttpHeaders.hasVaryAll(responseHeaders)) { // "*" means that this will be treated as uncacheable anyway. return null; } - Set varyFields = OkHeaders.varyFields(responseHeaders); + Set varyFields = HttpHeaders.varyFields(responseHeaders); if (varyFields.isEmpty()) { return new Headers.Builder().build(); } @@ -212,11 +212,11 @@ public final class JavaApiConverter { // Build a cache request for the response to use. Headers responseHeaders = createHeaders(javaResponse.getHeaders()); Headers varyHeaders; - if (OkHeaders.hasVaryAll(responseHeaders)) { + if (HttpHeaders.hasVaryAll(responseHeaders)) { // "*" means that this will be treated as uncacheable anyway. varyHeaders = new Headers.Builder().build(); } else { - varyHeaders = OkHeaders.varyHeaders(request.headers(), responseHeaders); + varyHeaders = HttpHeaders.varyHeaders(request.headers(), responseHeaders); } Request cacheRequest = new Request.Builder() @@ -519,7 +519,7 @@ public final class JavaApiConverter { @Override public long contentLength() { - return OkHeaders.contentLength(okHeaders); + return HttpHeaders.contentLength(okHeaders); } @Override public BufferedSource source() { diff --git a/okhttp-android-support/src/test/java/okhttp3/internal/huc/CacheAdapterTest.java b/okhttp-android-support/src/test/java/okhttp3/internal/huc/CacheAdapterTest.java index 2711dd8ee..53470ce87 100644 --- a/okhttp-android-support/src/test/java/okhttp3/internal/huc/CacheAdapterTest.java +++ b/okhttp-android-support/src/test/java/okhttp3/internal/huc/CacheAdapterTest.java @@ -29,13 +29,12 @@ import java.util.List; import java.util.Map; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLPeerUnverifiedException; import okhttp3.AbstractResponseCache; import okhttp3.OkHttpClient; import okhttp3.OkUrlFactory; import okhttp3.RecordingHostnameVerifier; import okhttp3.internal.Internal; -import okhttp3.internal.InternalCache; +import okhttp3.internal.cache.InternalCache; import okhttp3.internal.tls.SslClient; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; diff --git a/okhttp-android-support/src/test/java/okhttp3/internal/huc/ResponseCacheTest.java b/okhttp-android-support/src/test/java/okhttp3/internal/huc/ResponseCacheTest.java index 3774c323c..818424549 100644 --- a/okhttp-android-support/src/test/java/okhttp3/internal/huc/ResponseCacheTest.java +++ b/okhttp-android-support/src/test/java/okhttp3/internal/huc/ResponseCacheTest.java @@ -62,7 +62,7 @@ import okhttp3.OkHttpClient; import okhttp3.OkUrlFactory; import okhttp3.RecordingHostnameVerifier; import okhttp3.internal.Internal; -import okhttp3.internal.InternalCache; +import okhttp3.internal.cache.InternalCache; import okhttp3.internal.tls.SslClient; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; diff --git a/okhttp-logging-interceptor/src/main/java/okhttp3/logging/HttpLoggingInterceptor.java b/okhttp-logging-interceptor/src/main/java/okhttp3/logging/HttpLoggingInterceptor.java index f86b51523..cf9c686fd 100644 --- a/okhttp-logging-interceptor/src/main/java/okhttp3/logging/HttpLoggingInterceptor.java +++ b/okhttp-logging-interceptor/src/main/java/okhttp3/logging/HttpLoggingInterceptor.java @@ -30,12 +30,12 @@ import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; import okhttp3.ResponseBody; -import okhttp3.internal.Platform; -import okhttp3.internal.http.OkHeaders; +import okhttp3.internal.http.HttpHeaders; +import okhttp3.internal.platform.Platform; import okio.Buffer; import okio.BufferedSource; -import static okhttp3.internal.Platform.INFO; +import static okhttp3.internal.platform.Platform.INFO; /** * An OkHttp interceptor which logs request and response information. Can be applied as an @@ -229,7 +229,7 @@ public final class HttpLoggingInterceptor implements Interceptor { logger.log(headers.name(i) + ": " + headers.value(i)); } - if (!logBody || !OkHeaders.hasBody(response)) { + if (!logBody || !HttpHeaders.hasBody(response)) { logger.log("<-- END HTTP"); } else if (bodyEncoded(response.headers())) { logger.log("<-- END HTTP (encoded body omitted)"); diff --git a/okhttp-tests/src/test/java/okhttp3/CertificateChainCleanerTest.java b/okhttp-tests/src/test/java/okhttp3/CertificateChainCleanerTest.java index 261c99f8b..d3e0cb876 100644 --- a/okhttp-tests/src/test/java/okhttp3/CertificateChainCleanerTest.java +++ b/okhttp-tests/src/test/java/okhttp3/CertificateChainCleanerTest.java @@ -21,8 +21,8 @@ import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.List; import javax.net.ssl.SSLPeerUnverifiedException; -import okhttp3.internal.tls.HeldCertificate; import okhttp3.internal.tls.CertificateChainCleaner; +import okhttp3.internal.tls.HeldCertificate; import org.junit.Test; import static org.junit.Assert.assertEquals; diff --git a/okhttp-tests/src/test/java/okhttp3/ConnectionPoolTest.java b/okhttp-tests/src/test/java/okhttp3/ConnectionPoolTest.java index 84ebbc682..e5dde461f 100644 --- a/okhttp-tests/src/test/java/okhttp3/ConnectionPoolTest.java +++ b/okhttp-tests/src/test/java/okhttp3/ConnectionPoolTest.java @@ -24,8 +24,8 @@ import java.util.concurrent.TimeUnit; import javax.net.SocketFactory; import okhttp3.internal.Internal; import okhttp3.internal.RecordingOkAuthenticator; -import okhttp3.internal.http.StreamAllocation; -import okhttp3.internal.io.RealConnection; +import okhttp3.internal.connection.RealConnection; +import okhttp3.internal.connection.StreamAllocation; import org.junit.Test; import static org.junit.Assert.assertEquals; diff --git a/okhttp-tests/src/test/java/okhttp3/internal/http/CookiesTest.java b/okhttp-tests/src/test/java/okhttp3/CookiesTest.java similarity index 98% rename from okhttp-tests/src/test/java/okhttp3/internal/http/CookiesTest.java rename to okhttp-tests/src/test/java/okhttp3/CookiesTest.java index bf01f36fa..043621d4e 100644 --- a/okhttp-tests/src/test/java/okhttp3/internal/http/CookiesTest.java +++ b/okhttp-tests/src/test/java/okhttp3/CookiesTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package okhttp3.internal.http; +package okhttp3; import java.io.IOException; import java.net.CookieHandler; @@ -27,12 +27,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import okhttp3.Call; -import okhttp3.HttpUrl; -import okhttp3.JavaNetCookieJar; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; diff --git a/okhttp-tests/src/test/java/okhttp3/DelegatingSSLSocketFactory.java b/okhttp-tests/src/test/java/okhttp3/DelegatingSSLSocketFactory.java index 5a14d0fbd..5a5a3dc20 100644 --- a/okhttp-tests/src/test/java/okhttp3/DelegatingSSLSocketFactory.java +++ b/okhttp-tests/src/test/java/okhttp3/DelegatingSSLSocketFactory.java @@ -18,7 +18,6 @@ package okhttp3; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; -import java.net.UnknownHostException; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; diff --git a/okhttp-tests/src/test/java/okhttp3/DispatcherTest.java b/okhttp-tests/src/test/java/okhttp3/DispatcherTest.java index 6c0490146..b49379dff 100644 --- a/okhttp-tests/src/test/java/okhttp3/DispatcherTest.java +++ b/okhttp-tests/src/test/java/okhttp3/DispatcherTest.java @@ -1,7 +1,6 @@ package okhttp3; import java.io.IOException; -import java.io.InterruptedIOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; diff --git a/okhttp-tests/src/test/java/okhttp3/internal/http/HeadersTest.java b/okhttp-tests/src/test/java/okhttp3/HeadersTest.java similarity index 98% rename from okhttp-tests/src/test/java/okhttp3/internal/http/HeadersTest.java rename to okhttp-tests/src/test/java/okhttp3/HeadersTest.java index 84f37d13a..4ac17fed1 100644 --- a/okhttp-tests/src/test/java/okhttp3/internal/http/HeadersTest.java +++ b/okhttp-tests/src/test/java/okhttp3/HeadersTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal.http; +package okhttp3; import java.io.IOException; import java.util.Arrays; @@ -21,11 +21,8 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import okhttp3.Headers; -import okhttp3.Protocol; -import okhttp3.Request; -import okhttp3.Response; import okhttp3.internal.framed.Header; +import okhttp3.internal.http.Http2xStream; import org.junit.Assert; import org.junit.Test; diff --git a/okhttp-tests/src/test/java/okhttp3/internal/DiskLruCacheTest.java b/okhttp-tests/src/test/java/okhttp3/internal/cache/DiskLruCacheTest.java similarity index 99% rename from okhttp-tests/src/test/java/okhttp3/internal/DiskLruCacheTest.java rename to okhttp-tests/src/test/java/okhttp3/internal/cache/DiskLruCacheTest.java index be2d0be61..d4ae88b84 100644 --- a/okhttp-tests/src/test/java/okhttp3/internal/DiskLruCacheTest.java +++ b/okhttp-tests/src/test/java/okhttp3/internal/cache/DiskLruCacheTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal; +package okhttp3.internal.cache; import java.io.File; import java.io.IOException; @@ -25,6 +25,7 @@ import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; import java.util.concurrent.Executor; +import okhttp3.internal.io.FaultyFileSystem; import okhttp3.internal.io.FileSystem; import okio.BufferedSink; import okio.BufferedSource; @@ -37,10 +38,10 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.junit.rules.Timeout; -import static okhttp3.internal.DiskLruCache.JOURNAL_FILE; -import static okhttp3.internal.DiskLruCache.JOURNAL_FILE_BACKUP; -import static okhttp3.internal.DiskLruCache.MAGIC; -import static okhttp3.internal.DiskLruCache.VERSION_1; +import static okhttp3.internal.cache.DiskLruCache.JOURNAL_FILE; +import static okhttp3.internal.cache.DiskLruCache.JOURNAL_FILE_BACKUP; +import static okhttp3.internal.cache.DiskLruCache.MAGIC; +import static okhttp3.internal.cache.DiskLruCache.VERSION_1; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; diff --git a/okhttp-tests/src/test/java/okhttp3/internal/ConnectionSpecSelectorTest.java b/okhttp-tests/src/test/java/okhttp3/internal/connection/ConnectionSpecSelectorTest.java similarity index 98% rename from okhttp-tests/src/test/java/okhttp3/internal/ConnectionSpecSelectorTest.java rename to okhttp-tests/src/test/java/okhttp3/internal/connection/ConnectionSpecSelectorTest.java index 96c6585a3..b0b06e9f8 100644 --- a/okhttp-tests/src/test/java/okhttp3/internal/ConnectionSpecSelectorTest.java +++ b/okhttp-tests/src/test/java/okhttp3/internal/connection/ConnectionSpecSelectorTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal; +package okhttp3.internal.connection; import java.io.IOException; import java.security.cert.CertificateException; @@ -24,6 +24,7 @@ import javax.net.ssl.SSLHandshakeException; import javax.net.ssl.SSLSocket; import okhttp3.ConnectionSpec; import okhttp3.TlsVersion; +import okhttp3.internal.Internal; import okhttp3.internal.tls.SslClient; import org.junit.Test; diff --git a/okhttp-tests/src/test/java/okhttp3/internal/http/RouteExceptionTest.java b/okhttp-tests/src/test/java/okhttp3/internal/connection/RouteExceptionTest.java similarity index 97% rename from okhttp-tests/src/test/java/okhttp3/internal/http/RouteExceptionTest.java rename to okhttp-tests/src/test/java/okhttp3/internal/connection/RouteExceptionTest.java index 1a0c2d8f0..209d79d5c 100644 --- a/okhttp-tests/src/test/java/okhttp3/internal/http/RouteExceptionTest.java +++ b/okhttp-tests/src/test/java/okhttp3/internal/connection/RouteExceptionTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal.http; +package okhttp3.internal.connection; import java.io.IOException; import org.junit.Test; diff --git a/okhttp-tests/src/test/java/okhttp3/internal/http/RouteSelectorTest.java b/okhttp-tests/src/test/java/okhttp3/internal/connection/RouteSelectorTest.java similarity index 99% rename from okhttp-tests/src/test/java/okhttp3/internal/http/RouteSelectorTest.java rename to okhttp-tests/src/test/java/okhttp3/internal/connection/RouteSelectorTest.java index b1e3fca30..c5418e1b5 100644 --- a/okhttp-tests/src/test/java/okhttp3/internal/http/RouteSelectorTest.java +++ b/okhttp-tests/src/test/java/okhttp3/internal/connection/RouteSelectorTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal.http; +package okhttp3.internal.connection; import java.io.IOException; import java.net.InetAddress; @@ -37,8 +37,8 @@ import okhttp3.ConnectionSpec; import okhttp3.FakeDns; import okhttp3.Protocol; import okhttp3.Route; -import okhttp3.internal.RouteDatabase; import okhttp3.internal.Util; +import okhttp3.internal.http.RecordingProxySelector; import okhttp3.internal.tls.SslClient; import org.junit.Before; import org.junit.Test; diff --git a/okhttp-tests/src/test/java/okhttp3/internal/FaultyFileSystem.java b/okhttp-tests/src/test/java/okhttp3/internal/io/FaultyFileSystem.java similarity index 97% rename from okhttp-tests/src/test/java/okhttp3/internal/FaultyFileSystem.java rename to okhttp-tests/src/test/java/okhttp3/internal/io/FaultyFileSystem.java index 3f237d0ad..40aca93ad 100644 --- a/okhttp-tests/src/test/java/okhttp3/internal/FaultyFileSystem.java +++ b/okhttp-tests/src/test/java/okhttp3/internal/io/FaultyFileSystem.java @@ -13,14 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal; +package okhttp3.internal.io; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.LinkedHashSet; import java.util.Set; -import okhttp3.internal.io.FileSystem; import okio.Buffer; import okio.ForwardingSink; import okio.Sink; diff --git a/okhttp-tests/src/test/java/okhttp3/internal/Jdk9PlatformTest.java b/okhttp-tests/src/test/java/okhttp3/internal/platform/Jdk9PlatformTest.java similarity index 92% rename from okhttp-tests/src/test/java/okhttp3/internal/Jdk9PlatformTest.java rename to okhttp-tests/src/test/java/okhttp3/internal/platform/Jdk9PlatformTest.java index ed6deba9c..ada8f7896 100644 --- a/okhttp-tests/src/test/java/okhttp3/internal/Jdk9PlatformTest.java +++ b/okhttp-tests/src/test/java/okhttp3/internal/platform/Jdk9PlatformTest.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal; +package okhttp3.internal.platform; import org.junit.Test; -import static okhttp3.internal.PlatformTest.getPlatform; +import static okhttp3.internal.platform.PlatformTest.getPlatform; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assume.assumeTrue; diff --git a/okhttp-tests/src/test/java/okhttp3/internal/JdkWithJettyBootPlatformTest.java b/okhttp-tests/src/test/java/okhttp3/internal/platform/JdkWithJettyBootPlatformTest.java similarity index 90% rename from okhttp-tests/src/test/java/okhttp3/internal/JdkWithJettyBootPlatformTest.java rename to okhttp-tests/src/test/java/okhttp3/internal/platform/JdkWithJettyBootPlatformTest.java index 04853ac10..afe7145a0 100644 --- a/okhttp-tests/src/test/java/okhttp3/internal/JdkWithJettyBootPlatformTest.java +++ b/okhttp-tests/src/test/java/okhttp3/internal/platform/JdkWithJettyBootPlatformTest.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal; +package okhttp3.internal.platform; import org.junit.Test; -import static okhttp3.internal.PlatformTest.getPlatform; +import static okhttp3.internal.platform.PlatformTest.getPlatform; import static org.junit.Assert.assertNotNull; import static org.junit.Assume.assumeTrue; diff --git a/okhttp-tests/src/test/java/okhttp3/internal/OptionalMethodTest.java b/okhttp-tests/src/test/java/okhttp3/internal/platform/OptionalMethodTest.java similarity index 99% rename from okhttp-tests/src/test/java/okhttp3/internal/OptionalMethodTest.java rename to okhttp-tests/src/test/java/okhttp3/internal/platform/OptionalMethodTest.java index 08e025c5d..e6c51fad6 100644 --- a/okhttp-tests/src/test/java/okhttp3/internal/OptionalMethodTest.java +++ b/okhttp-tests/src/test/java/okhttp3/internal/platform/OptionalMethodTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package okhttp3.internal; +package okhttp3.internal.platform; import java.io.IOException; import java.lang.reflect.InvocationTargetException; diff --git a/okhttp-tests/src/test/java/okhttp3/internal/PlatformTest.java b/okhttp-tests/src/test/java/okhttp3/internal/platform/PlatformTest.java similarity index 91% rename from okhttp-tests/src/test/java/okhttp3/internal/PlatformTest.java rename to okhttp-tests/src/test/java/okhttp3/internal/platform/PlatformTest.java index 43e205d7d..863312ee0 100644 --- a/okhttp-tests/src/test/java/okhttp3/internal/PlatformTest.java +++ b/okhttp-tests/src/test/java/okhttp3/internal/platform/PlatformTest.java @@ -13,13 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal; +package okhttp3.internal.platform; import org.junit.Test; public class PlatformTest { - @Test - public void alwaysBuilds() { + @Test public void alwaysBuilds() { new Platform(); } diff --git a/okhttp-urlconnection/src/main/java/okhttp3/JavaNetCookieJar.java b/okhttp-urlconnection/src/main/java/okhttp3/JavaNetCookieJar.java index 6af8a69b6..9d83c8b3f 100644 --- a/okhttp-urlconnection/src/main/java/okhttp3/JavaNetCookieJar.java +++ b/okhttp-urlconnection/src/main/java/okhttp3/JavaNetCookieJar.java @@ -22,11 +22,11 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; -import okhttp3.internal.Platform; +import okhttp3.internal.platform.Platform; -import static okhttp3.internal.Platform.WARN; import static okhttp3.internal.Util.delimiterOffset; import static okhttp3.internal.Util.trimSubstring; +import static okhttp3.internal.platform.Platform.WARN; /** A cookie jar that delegates to a {@link java.net.CookieHandler}. */ public final class JavaNetCookieJar implements CookieJar { diff --git a/okhttp-urlconnection/src/main/java/okhttp3/internal/huc/OkHttpURLConnection.java b/okhttp-urlconnection/src/main/java/okhttp3/internal/huc/OkHttpURLConnection.java index 5ff05b84e..a7632c814 100644 --- a/okhttp-urlconnection/src/main/java/okhttp3/internal/huc/OkHttpURLConnection.java +++ b/okhttp-urlconnection/src/main/java/okhttp3/internal/huc/OkHttpURLConnection.java @@ -49,16 +49,16 @@ import okhttp3.Request; import okhttp3.Response; import okhttp3.internal.Internal; import okhttp3.internal.JavaNetHeaders; -import okhttp3.internal.Platform; import okhttp3.internal.URLFilter; import okhttp3.internal.Util; import okhttp3.internal.Version; import okhttp3.internal.http.HttpDate; +import okhttp3.internal.http.HttpHeaders; import okhttp3.internal.http.HttpMethod; -import okhttp3.internal.http.OkHeaders; import okhttp3.internal.http.StatusLine; +import okhttp3.internal.platform.Platform; -import static okhttp3.internal.Platform.WARN; +import static okhttp3.internal.platform.Platform.WARN; /** * This implementation uses {@linkplain Call} to send requests and receive responses. @@ -152,7 +152,7 @@ public final class OkHttpURLConnection extends HttpURLConnection implements Call @Override public InputStream getErrorStream() { try { Response response = getResponse(); - if (OkHeaders.hasBody(response) && response.code() >= HTTP_BAD_REQUEST) { + if (HttpHeaders.hasBody(response) && response.code() >= HTTP_BAD_REQUEST) { return response.body().byteStream(); } return null; diff --git a/okhttp-urlconnection/src/test/java/okhttp3/internal/huc/URLEncodingTest.java b/okhttp-urlconnection/src/test/java/okhttp3/internal/huc/URLEncodingTest.java index 1cc63d8f3..b93d87682 100644 --- a/okhttp-urlconnection/src/test/java/okhttp3/internal/huc/URLEncodingTest.java +++ b/okhttp-urlconnection/src/test/java/okhttp3/internal/huc/URLEncodingTest.java @@ -27,9 +27,9 @@ import okhttp3.OkUrlFactory; import okhttp3.Request; import okhttp3.Response; import okhttp3.internal.Internal; -import okhttp3.internal.InternalCache; -import okhttp3.internal.http.CacheRequest; -import okhttp3.internal.http.CacheStrategy; +import okhttp3.internal.cache.CacheRequest; +import okhttp3.internal.cache.CacheStrategy; +import okhttp3.internal.cache.InternalCache; import org.junit.Ignore; import org.junit.Test; diff --git a/okhttp-ws/src/main/java/okhttp3/ws/WebSocketCall.java b/okhttp-ws/src/main/java/okhttp3/ws/WebSocketCall.java index 1a7d883b1..6178a16b6 100644 --- a/okhttp-ws/src/main/java/okhttp3/ws/WebSocketCall.java +++ b/okhttp-ws/src/main/java/okhttp3/ws/WebSocketCall.java @@ -31,7 +31,7 @@ import okhttp3.Request; import okhttp3.Response; import okhttp3.internal.Internal; import okhttp3.internal.Util; -import okhttp3.internal.http.StreamAllocation; +import okhttp3.internal.connection.StreamAllocation; import okhttp3.internal.ws.RealWebSocket; import okhttp3.internal.ws.WebSocketProtocol; import okio.ByteString; diff --git a/okhttp/src/main/java/okhttp3/Cache.java b/okhttp/src/main/java/okhttp3/Cache.java index 086982d03..d70ac4320 100644 --- a/okhttp/src/main/java/okhttp3/Cache.java +++ b/okhttp/src/main/java/okhttp3/Cache.java @@ -28,16 +28,16 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; -import okhttp3.internal.DiskLruCache; -import okhttp3.internal.InternalCache; -import okhttp3.internal.Platform; import okhttp3.internal.Util; -import okhttp3.internal.http.CacheRequest; -import okhttp3.internal.http.CacheStrategy; +import okhttp3.internal.cache.CacheRequest; +import okhttp3.internal.cache.CacheStrategy; +import okhttp3.internal.cache.DiskLruCache; +import okhttp3.internal.cache.InternalCache; +import okhttp3.internal.http.HttpHeaders; import okhttp3.internal.http.HttpMethod; -import okhttp3.internal.http.OkHeaders; import okhttp3.internal.http.StatusLine; import okhttp3.internal.io.FileSystem; +import okhttp3.internal.platform.Platform; import okio.Buffer; import okio.BufferedSink; import okio.BufferedSource; @@ -235,7 +235,7 @@ public final class Cache implements Closeable, Flushable { return null; } - if (OkHeaders.hasVaryAll(response)) { + if (HttpHeaders.hasVaryAll(response)) { return null; } @@ -592,7 +592,7 @@ public final class Cache implements Closeable, Flushable { public Entry(Response response) { this.url = response.request().url().toString(); - this.varyHeaders = OkHeaders.varyHeaders(response); + this.varyHeaders = HttpHeaders.varyHeaders(response); this.requestMethod = response.request().method(); this.protocol = response.protocol(); this.code = response.code(); @@ -695,7 +695,7 @@ public final class Cache implements Closeable, Flushable { public boolean matches(Request request, Response response) { return url.equals(request.url().toString()) && requestMethod.equals(request.method()) - && OkHeaders.varyMatches(response, varyHeaders, request); + && HttpHeaders.varyMatches(response, varyHeaders, request); } public Response response(DiskLruCache.Snapshot snapshot) { diff --git a/okhttp/src/main/java/okhttp3/CacheControl.java b/okhttp/src/main/java/okhttp3/CacheControl.java index d8eb44614..9dcdbd3c2 100644 --- a/okhttp/src/main/java/okhttp3/CacheControl.java +++ b/okhttp/src/main/java/okhttp3/CacheControl.java @@ -1,7 +1,7 @@ package okhttp3; import java.util.concurrent.TimeUnit; -import okhttp3.internal.http.HeaderParser; +import okhttp3.internal.http.HttpHeaders; /** * A Cache-Control header with cache directives from a server or client. These directives set policy @@ -178,7 +178,7 @@ public final class CacheControl { int pos = 0; while (pos < value.length()) { int tokenStart = pos; - pos = HeaderParser.skipUntil(value, pos, "=,;"); + pos = HttpHeaders.skipUntil(value, pos, "=,;"); String directive = value.substring(tokenStart, pos).trim(); String parameter; @@ -187,20 +187,20 @@ public final class CacheControl { parameter = null; } else { pos++; // consume '=' - pos = HeaderParser.skipWhitespace(value, pos); + pos = HttpHeaders.skipWhitespace(value, pos); // quoted string if (pos < value.length() && value.charAt(pos) == '\"') { pos++; // consume '"' open quote int parameterStart = pos; - pos = HeaderParser.skipUntil(value, pos, "\""); + pos = HttpHeaders.skipUntil(value, pos, "\""); parameter = value.substring(parameterStart, pos); pos++; // consume '"' close quote (if necessary) // unquoted string } else { int parameterStart = pos; - pos = HeaderParser.skipUntil(value, pos, ",;"); + pos = HttpHeaders.skipUntil(value, pos, ",;"); parameter = value.substring(parameterStart, pos).trim(); } } @@ -210,9 +210,9 @@ public final class CacheControl { } else if ("no-store".equalsIgnoreCase(directive)) { noStore = true; } else if ("max-age".equalsIgnoreCase(directive)) { - maxAgeSeconds = HeaderParser.parseSeconds(parameter, -1); + maxAgeSeconds = HttpHeaders.parseSeconds(parameter, -1); } else if ("s-maxage".equalsIgnoreCase(directive)) { - sMaxAgeSeconds = HeaderParser.parseSeconds(parameter, -1); + sMaxAgeSeconds = HttpHeaders.parseSeconds(parameter, -1); } else if ("private".equalsIgnoreCase(directive)) { isPrivate = true; } else if ("public".equalsIgnoreCase(directive)) { @@ -220,9 +220,9 @@ public final class CacheControl { } else if ("must-revalidate".equalsIgnoreCase(directive)) { mustRevalidate = true; } else if ("max-stale".equalsIgnoreCase(directive)) { - maxStaleSeconds = HeaderParser.parseSeconds(parameter, Integer.MAX_VALUE); + maxStaleSeconds = HttpHeaders.parseSeconds(parameter, Integer.MAX_VALUE); } else if ("min-fresh".equalsIgnoreCase(directive)) { - minFreshSeconds = HeaderParser.parseSeconds(parameter, -1); + minFreshSeconds = HttpHeaders.parseSeconds(parameter, -1); } else if ("only-if-cached".equalsIgnoreCase(directive)) { onlyIfCached = true; } else if ("no-transform".equalsIgnoreCase(directive)) { diff --git a/okhttp/src/main/java/okhttp3/ConnectionPool.java b/okhttp/src/main/java/okhttp3/ConnectionPool.java index d6391c3f8..2b4563c33 100644 --- a/okhttp/src/main/java/okhttp3/ConnectionPool.java +++ b/okhttp/src/main/java/okhttp3/ConnectionPool.java @@ -26,14 +26,14 @@ import java.util.concurrent.Executor; import java.util.concurrent.SynchronousQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import okhttp3.internal.Platform; -import okhttp3.internal.RouteDatabase; import okhttp3.internal.Util; -import okhttp3.internal.http.StreamAllocation; -import okhttp3.internal.io.RealConnection; +import okhttp3.internal.connection.RealConnection; +import okhttp3.internal.connection.RouteDatabase; +import okhttp3.internal.connection.StreamAllocation; +import okhttp3.internal.platform.Platform; -import static okhttp3.internal.Platform.WARN; import static okhttp3.internal.Util.closeQuietly; +import static okhttp3.internal.platform.Platform.WARN; /** * Manages reuse of HTTP and SPDY connections for reduced network latency. HTTP requests that share diff --git a/okhttp/src/main/java/okhttp3/OkHttpClient.java b/okhttp/src/main/java/okhttp3/OkHttpClient.java index d35c44471..6402b0202 100644 --- a/okhttp/src/main/java/okhttp3/OkHttpClient.java +++ b/okhttp/src/main/java/okhttp3/OkHttpClient.java @@ -34,12 +34,12 @@ import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509TrustManager; import okhttp3.internal.Internal; -import okhttp3.internal.InternalCache; -import okhttp3.internal.Platform; -import okhttp3.internal.RouteDatabase; import okhttp3.internal.Util; -import okhttp3.internal.http.StreamAllocation; -import okhttp3.internal.io.RealConnection; +import okhttp3.internal.cache.InternalCache; +import okhttp3.internal.connection.RealConnection; +import okhttp3.internal.connection.RouteDatabase; +import okhttp3.internal.connection.StreamAllocation; +import okhttp3.internal.platform.Platform; import okhttp3.internal.tls.CertificateChainCleaner; import okhttp3.internal.tls.OkHostnameVerifier; diff --git a/okhttp/src/main/java/okhttp3/RealCall.java b/okhttp/src/main/java/okhttp3/RealCall.java index 06c7c4b15..4aa45ef44 100644 --- a/okhttp/src/main/java/okhttp3/RealCall.java +++ b/okhttp/src/main/java/okhttp3/RealCall.java @@ -19,16 +19,16 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; import okhttp3.internal.NamedRunnable; -import okhttp3.internal.Platform; +import okhttp3.internal.cache.CacheInterceptor; +import okhttp3.internal.connection.ConnectInterceptor; +import okhttp3.internal.connection.StreamAllocation; import okhttp3.internal.http.BridgeInterceptor; -import okhttp3.internal.http.CacheInterceptor; import okhttp3.internal.http.CallServerInterceptor; -import okhttp3.internal.http.ConnectInterceptor; import okhttp3.internal.http.RealInterceptorChain; import okhttp3.internal.http.RetryAndFollowUpInterceptor; -import okhttp3.internal.http.StreamAllocation; +import okhttp3.internal.platform.Platform; -import static okhttp3.internal.Platform.INFO; +import static okhttp3.internal.platform.Platform.INFO; final class RealCall implements Call { private final OkHttpClient client; diff --git a/okhttp/src/main/java/okhttp3/Response.java b/okhttp/src/main/java/okhttp3/Response.java index 4b1928404..08c8f9d04 100644 --- a/okhttp/src/main/java/okhttp3/Response.java +++ b/okhttp/src/main/java/okhttp3/Response.java @@ -19,7 +19,7 @@ import java.io.Closeable; import java.io.IOException; import java.util.Collections; import java.util.List; -import okhttp3.internal.http.OkHeaders; +import okhttp3.internal.http.HttpHeaders; import okio.Buffer; import okio.BufferedSource; @@ -234,7 +234,7 @@ public final class Response implements Closeable { } else { return Collections.emptyList(); } - return OkHeaders.parseChallenges(headers(), responseField); + return HttpHeaders.parseChallenges(headers(), responseField); } /** diff --git a/okhttp/src/main/java/okhttp3/internal/Internal.java b/okhttp/src/main/java/okhttp3/internal/Internal.java index 1f4ff952a..48c911a26 100644 --- a/okhttp/src/main/java/okhttp3/internal/Internal.java +++ b/okhttp/src/main/java/okhttp3/internal/Internal.java @@ -25,8 +25,10 @@ import okhttp3.ConnectionSpec; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; -import okhttp3.internal.http.StreamAllocation; -import okhttp3.internal.io.RealConnection; +import okhttp3.internal.cache.InternalCache; +import okhttp3.internal.connection.RealConnection; +import okhttp3.internal.connection.RouteDatabase; +import okhttp3.internal.connection.StreamAllocation; /** * Escalate internal APIs in {@code okhttp3} so they can be used from OkHttp's implementation diff --git a/okhttp/src/main/java/okhttp3/internal/http/CacheInterceptor.java b/okhttp/src/main/java/okhttp3/internal/cache/CacheInterceptor.java similarity index 90% rename from okhttp/src/main/java/okhttp3/internal/http/CacheInterceptor.java rename to okhttp/src/main/java/okhttp3/internal/cache/CacheInterceptor.java index aa3a85d24..424db32b3 100644 --- a/okhttp/src/main/java/okhttp3/internal/http/CacheInterceptor.java +++ b/okhttp/src/main/java/okhttp3/internal/cache/CacheInterceptor.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal.http; +package okhttp3.internal.cache; import java.io.IOException; import java.util.Date; @@ -26,7 +26,10 @@ import okhttp3.Request; import okhttp3.Response; import okhttp3.ResponseBody; import okhttp3.internal.Internal; -import okhttp3.internal.InternalCache; +import okhttp3.internal.http.HttpHeaders; +import okhttp3.internal.http.HttpMethod; +import okhttp3.internal.http.HttpStream; +import okhttp3.internal.http.RealResponseBody; import okio.Buffer; import okio.BufferedSink; import okio.BufferedSource; @@ -136,7 +139,7 @@ public final class CacheInterceptor implements Interceptor { .networkResponse(stripBody(networkResponse)) .build(); - if (OkHeaders.hasBody(response)) { + if (HttpHeaders.hasBody(response)) { CacheRequest cacheRequest = maybeCache(response, networkResponse.request(), cache); response = cacheWritingResponse(cacheRequest, response); } @@ -264,7 +267,7 @@ public final class CacheInterceptor implements Interceptor { if ("Warning".equalsIgnoreCase(fieldName) && value.startsWith("1")) { continue; // Drop 100-level freshness warnings. } - if (!OkHeaders.isEndToEnd(fieldName) || networkHeaders.get(fieldName) == null) { + if (!isEndToEnd(fieldName) || networkHeaders.get(fieldName) == null) { Internal.instance.addLenient(result, fieldName, value); } } @@ -274,11 +277,26 @@ public final class CacheInterceptor implements Interceptor { if ("Content-Length".equalsIgnoreCase(fieldName)) { continue; // Ignore content-length headers of validating responses. } - if (OkHeaders.isEndToEnd(fieldName)) { + if (isEndToEnd(fieldName)) { Internal.instance.addLenient(result, fieldName, networkHeaders.value(i)); } } return result.build(); } + + /** + * Returns true if {@code fieldName} is an end-to-end HTTP header, as defined by RFC 2616, + * 13.5.1. + */ + static boolean isEndToEnd(String fieldName) { + return !"Connection".equalsIgnoreCase(fieldName) + && !"Keep-Alive".equalsIgnoreCase(fieldName) + && !"Proxy-Authenticate".equalsIgnoreCase(fieldName) + && !"Proxy-Authorization".equalsIgnoreCase(fieldName) + && !"TE".equalsIgnoreCase(fieldName) + && !"Trailers".equalsIgnoreCase(fieldName) + && !"Transfer-Encoding".equalsIgnoreCase(fieldName) + && !"Upgrade".equalsIgnoreCase(fieldName); + } } diff --git a/okhttp/src/main/java/okhttp3/internal/http/CacheRequest.java b/okhttp/src/main/java/okhttp3/internal/cache/CacheRequest.java similarity index 95% rename from okhttp/src/main/java/okhttp3/internal/http/CacheRequest.java rename to okhttp/src/main/java/okhttp3/internal/cache/CacheRequest.java index 12c3134e8..b4432b4e1 100644 --- a/okhttp/src/main/java/okhttp3/internal/http/CacheRequest.java +++ b/okhttp/src/main/java/okhttp3/internal/cache/CacheRequest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal.http; +package okhttp3.internal.cache; import java.io.IOException; import okio.Sink; diff --git a/okhttp/src/main/java/okhttp3/internal/http/CacheStrategy.java b/okhttp/src/main/java/okhttp3/internal/cache/CacheStrategy.java similarity index 98% rename from okhttp/src/main/java/okhttp3/internal/http/CacheStrategy.java rename to okhttp/src/main/java/okhttp3/internal/cache/CacheStrategy.java index 7aa8af1a4..e1f97613e 100644 --- a/okhttp/src/main/java/okhttp3/internal/http/CacheStrategy.java +++ b/okhttp/src/main/java/okhttp3/internal/cache/CacheStrategy.java @@ -13,13 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal.http; +package okhttp3.internal.cache; import java.util.Date; import okhttp3.CacheControl; import okhttp3.Headers; import okhttp3.Request; import okhttp3.Response; +import okhttp3.internal.http.HttpDate; +import okhttp3.internal.http.HttpHeaders; +import okhttp3.internal.http.StatusLine; import static java.net.HttpURLConnection.HTTP_BAD_METHOD; import static java.net.HttpURLConnection.HTTP_GONE; @@ -155,7 +158,7 @@ public final class CacheStrategy { } else if ("ETag".equalsIgnoreCase(fieldName)) { etag = value; } else if ("Age".equalsIgnoreCase(fieldName)) { - ageSeconds = HeaderParser.parseSeconds(value, -1); + ageSeconds = HttpHeaders.parseSeconds(value, -1); } } } diff --git a/okhttp/src/main/java/okhttp3/internal/DiskLruCache.java b/okhttp/src/main/java/okhttp3/internal/cache/DiskLruCache.java similarity index 99% rename from okhttp/src/main/java/okhttp3/internal/DiskLruCache.java rename to okhttp/src/main/java/okhttp3/internal/cache/DiskLruCache.java index 097686bf2..4165d9e74 100644 --- a/okhttp/src/main/java/okhttp3/internal/DiskLruCache.java +++ b/okhttp/src/main/java/okhttp3/internal/cache/DiskLruCache.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal; +package okhttp3.internal.cache; import java.io.Closeable; import java.io.EOFException; @@ -32,7 +32,9 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; +import okhttp3.internal.Util; import okhttp3.internal.io.FileSystem; +import okhttp3.internal.platform.Platform; import okio.Buffer; import okio.BufferedSink; import okio.BufferedSource; @@ -41,7 +43,7 @@ import okio.Sink; import okio.Source; import okio.Timeout; -import static okhttp3.internal.Platform.WARN; +import static okhttp3.internal.platform.Platform.WARN; /** * A cache that uses a bounded amount of space on a filesystem. Each cache entry has a string key diff --git a/okhttp/src/main/java/okhttp3/internal/FaultHidingSink.java b/okhttp/src/main/java/okhttp3/internal/cache/FaultHidingSink.java similarity index 98% rename from okhttp/src/main/java/okhttp3/internal/FaultHidingSink.java rename to okhttp/src/main/java/okhttp3/internal/cache/FaultHidingSink.java index e77f6bb44..b10fddb95 100644 --- a/okhttp/src/main/java/okhttp3/internal/FaultHidingSink.java +++ b/okhttp/src/main/java/okhttp3/internal/cache/FaultHidingSink.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal; +package okhttp3.internal.cache; import java.io.IOException; import okio.Buffer; diff --git a/okhttp/src/main/java/okhttp3/internal/InternalCache.java b/okhttp/src/main/java/okhttp3/internal/cache/InternalCache.java similarity index 93% rename from okhttp/src/main/java/okhttp3/internal/InternalCache.java rename to okhttp/src/main/java/okhttp3/internal/cache/InternalCache.java index 9752002bc..e68edbf6e 100644 --- a/okhttp/src/main/java/okhttp3/internal/InternalCache.java +++ b/okhttp/src/main/java/okhttp3/internal/cache/InternalCache.java @@ -13,13 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal; +package okhttp3.internal.cache; import java.io.IOException; import okhttp3.Request; import okhttp3.Response; -import okhttp3.internal.http.CacheRequest; -import okhttp3.internal.http.CacheStrategy; /** * OkHttp's internal cache interface. Applications shouldn't implement this: instead use {@link diff --git a/okhttp/src/main/java/okhttp3/internal/http/ConnectInterceptor.java b/okhttp/src/main/java/okhttp3/internal/connection/ConnectInterceptor.java similarity index 93% rename from okhttp/src/main/java/okhttp3/internal/http/ConnectInterceptor.java rename to okhttp/src/main/java/okhttp3/internal/connection/ConnectInterceptor.java index 5b935f1de..9e0107533 100644 --- a/okhttp/src/main/java/okhttp3/internal/http/ConnectInterceptor.java +++ b/okhttp/src/main/java/okhttp3/internal/connection/ConnectInterceptor.java @@ -14,14 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal.http; +package okhttp3.internal.connection; import java.io.IOException; import okhttp3.Interceptor; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; -import okhttp3.internal.io.RealConnection; +import okhttp3.internal.http.HttpStream; +import okhttp3.internal.http.RealInterceptorChain; /** Opens a connection to the target server and proceeds to the next interceptor. */ public final class ConnectInterceptor implements Interceptor { diff --git a/okhttp/src/main/java/okhttp3/internal/ConnectionSpecSelector.java b/okhttp/src/main/java/okhttp3/internal/connection/ConnectionSpecSelector.java similarity index 98% rename from okhttp/src/main/java/okhttp3/internal/ConnectionSpecSelector.java rename to okhttp/src/main/java/okhttp3/internal/connection/ConnectionSpecSelector.java index 1393910b1..0b438bfa1 100644 --- a/okhttp/src/main/java/okhttp3/internal/ConnectionSpecSelector.java +++ b/okhttp/src/main/java/okhttp3/internal/connection/ConnectionSpecSelector.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal; +package okhttp3.internal.connection; import java.io.IOException; import java.io.InterruptedIOException; @@ -27,6 +27,7 @@ import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLProtocolException; import javax.net.ssl.SSLSocket; import okhttp3.ConnectionSpec; +import okhttp3.internal.Internal; /** * Handles the connection spec fallback strategy: When a secure socket connection fails due to a diff --git a/okhttp/src/main/java/okhttp3/internal/io/RealConnection.java b/okhttp/src/main/java/okhttp3/internal/connection/RealConnection.java similarity index 98% rename from okhttp/src/main/java/okhttp3/internal/io/RealConnection.java rename to okhttp/src/main/java/okhttp3/internal/connection/RealConnection.java index f641c9f0d..c21931b60 100644 --- a/okhttp/src/main/java/okhttp3/internal/io/RealConnection.java +++ b/okhttp/src/main/java/okhttp3/internal/connection/RealConnection.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal.io; +package okhttp3.internal.connection; import java.io.IOException; import java.lang.ref.Reference; @@ -41,17 +41,14 @@ import okhttp3.Protocol; import okhttp3.Request; import okhttp3.Response; import okhttp3.Route; -import okhttp3.internal.ConnectionSpecSelector; -import okhttp3.internal.Platform; import okhttp3.internal.Util; import okhttp3.internal.Version; import okhttp3.internal.framed.ErrorCode; import okhttp3.internal.framed.FramedConnection; import okhttp3.internal.framed.FramedStream; import okhttp3.internal.http.Http1xStream; -import okhttp3.internal.http.OkHeaders; -import okhttp3.internal.http.RouteException; -import okhttp3.internal.http.StreamAllocation; +import okhttp3.internal.http.HttpHeaders; +import okhttp3.internal.platform.Platform; import okhttp3.internal.tls.OkHostnameVerifier; import okio.BufferedSink; import okio.BufferedSource; @@ -294,7 +291,7 @@ public final class RealConnection extends FramedConnection.Listener implements C Response response = tunnelConnection.readResponse().request(tunnelRequest).build(); // The response body from a CONNECT should be empty, but if it is not then we should consume // it before proceeding. - long contentLength = OkHeaders.contentLength(response); + long contentLength = HttpHeaders.contentLength(response); if (contentLength == -1L) { contentLength = 0L; } diff --git a/okhttp/src/main/java/okhttp3/internal/RouteDatabase.java b/okhttp/src/main/java/okhttp3/internal/connection/RouteDatabase.java similarity index 97% rename from okhttp/src/main/java/okhttp3/internal/RouteDatabase.java rename to okhttp/src/main/java/okhttp3/internal/connection/RouteDatabase.java index 7df854004..1cc3f311b 100644 --- a/okhttp/src/main/java/okhttp3/internal/RouteDatabase.java +++ b/okhttp/src/main/java/okhttp3/internal/connection/RouteDatabase.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal; +package okhttp3.internal.connection; import java.util.LinkedHashSet; import java.util.Set; diff --git a/okhttp/src/main/java/okhttp3/internal/http/RouteException.java b/okhttp/src/main/java/okhttp3/internal/connection/RouteException.java similarity index 98% rename from okhttp/src/main/java/okhttp3/internal/http/RouteException.java rename to okhttp/src/main/java/okhttp3/internal/connection/RouteException.java index d18f04a77..5f5057661 100644 --- a/okhttp/src/main/java/okhttp3/internal/http/RouteException.java +++ b/okhttp/src/main/java/okhttp3/internal/connection/RouteException.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal.http; +package okhttp3.internal.connection; import java.io.IOException; import java.lang.reflect.InvocationTargetException; diff --git a/okhttp/src/main/java/okhttp3/internal/http/RouteSelector.java b/okhttp/src/main/java/okhttp3/internal/connection/RouteSelector.java similarity index 99% rename from okhttp/src/main/java/okhttp3/internal/http/RouteSelector.java rename to okhttp/src/main/java/okhttp3/internal/connection/RouteSelector.java index 3b5725cbe..95e9fbe5e 100644 --- a/okhttp/src/main/java/okhttp3/internal/http/RouteSelector.java +++ b/okhttp/src/main/java/okhttp3/internal/connection/RouteSelector.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal.http; +package okhttp3.internal.connection; import java.io.IOException; import java.net.InetAddress; @@ -28,7 +28,6 @@ import java.util.NoSuchElementException; import okhttp3.Address; import okhttp3.HttpUrl; import okhttp3.Route; -import okhttp3.internal.RouteDatabase; /** * Selects routes to connect to an origin server. Each connection requires a choice of proxy server, diff --git a/okhttp/src/main/java/okhttp3/internal/http/StreamAllocation.java b/okhttp/src/main/java/okhttp3/internal/connection/StreamAllocation.java similarity index 98% rename from okhttp/src/main/java/okhttp3/internal/http/StreamAllocation.java rename to okhttp/src/main/java/okhttp3/internal/connection/StreamAllocation.java index e5f3d75c0..92d421b66 100644 --- a/okhttp/src/main/java/okhttp3/internal/http/StreamAllocation.java +++ b/okhttp/src/main/java/okhttp3/internal/connection/StreamAllocation.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal.http; +package okhttp3.internal.connection; import java.io.IOException; import java.lang.ref.Reference; @@ -23,11 +23,12 @@ import okhttp3.ConnectionPool; import okhttp3.OkHttpClient; import okhttp3.Route; import okhttp3.internal.Internal; -import okhttp3.internal.RouteDatabase; import okhttp3.internal.Util; import okhttp3.internal.framed.ErrorCode; import okhttp3.internal.framed.StreamResetException; -import okhttp3.internal.io.RealConnection; +import okhttp3.internal.http.Http1xStream; +import okhttp3.internal.http.Http2xStream; +import okhttp3.internal.http.HttpStream; import static java.util.concurrent.TimeUnit.MILLISECONDS; diff --git a/okhttp/src/main/java/okhttp3/internal/framed/FramedConnection.java b/okhttp/src/main/java/okhttp3/internal/framed/FramedConnection.java index 336f466cd..3bdd7b351 100644 --- a/okhttp/src/main/java/okhttp3/internal/framed/FramedConnection.java +++ b/okhttp/src/main/java/okhttp3/internal/framed/FramedConnection.java @@ -32,16 +32,16 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import okhttp3.Protocol; import okhttp3.internal.NamedRunnable; -import okhttp3.internal.Platform; import okhttp3.internal.Util; +import okhttp3.internal.platform.Platform; import okio.Buffer; import okio.BufferedSink; import okio.BufferedSource; import okio.ByteString; import okio.Okio; -import static okhttp3.internal.Platform.INFO; import static okhttp3.internal.framed.Settings.DEFAULT_INITIAL_WINDOW_SIZE; +import static okhttp3.internal.platform.Platform.INFO; /** * A socket connection to a remote peer. A connection hosts streams which can send and receive diff --git a/okhttp/src/main/java/okhttp3/internal/http/BridgeInterceptor.java b/okhttp/src/main/java/okhttp3/internal/http/BridgeInterceptor.java index 90d8a0ae1..f8a720ff8 100644 --- a/okhttp/src/main/java/okhttp3/internal/http/BridgeInterceptor.java +++ b/okhttp/src/main/java/okhttp3/internal/http/BridgeInterceptor.java @@ -92,14 +92,14 @@ public final class BridgeInterceptor implements Interceptor { Response networkResponse = chain.proceed(requestBuilder.build()); - OkHeaders.receiveHeaders(cookieJar, userRequest.url(), networkResponse.headers()); + HttpHeaders.receiveHeaders(cookieJar, userRequest.url(), networkResponse.headers()); Response.Builder responseBuilder = networkResponse.newBuilder() .request(userRequest); if (transparentGzip && "gzip".equalsIgnoreCase(networkResponse.header("Content-Encoding")) - && OkHeaders.hasBody(networkResponse)) { + && HttpHeaders.hasBody(networkResponse)) { GzipSource responseBody = new GzipSource(networkResponse.body().source()); Headers strippedHeaders = networkResponse.headers().newBuilder() .removeAll("Content-Encoding") diff --git a/okhttp/src/main/java/okhttp3/internal/http/CallServerInterceptor.java b/okhttp/src/main/java/okhttp3/internal/http/CallServerInterceptor.java index 9a3f33ad1..4f72012b3 100644 --- a/okhttp/src/main/java/okhttp3/internal/http/CallServerInterceptor.java +++ b/okhttp/src/main/java/okhttp3/internal/http/CallServerInterceptor.java @@ -20,6 +20,7 @@ import java.net.ProtocolException; import okhttp3.Interceptor; import okhttp3.Request; import okhttp3.Response; +import okhttp3.internal.connection.StreamAllocation; import okio.BufferedSink; import okio.Okio; import okio.Sink; diff --git a/okhttp/src/main/java/okhttp3/internal/http/HeaderParser.java b/okhttp/src/main/java/okhttp3/internal/http/HeaderParser.java deleted file mode 100644 index 1e27c988c..000000000 --- a/okhttp/src/main/java/okhttp3/internal/http/HeaderParser.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * 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.internal.http; - -public final class HeaderParser { - /** - * Returns the next index in {@code input} at or after {@code pos} that contains a character from - * {@code characters}. Returns the input length if none of the requested characters can be found. - */ - public static int skipUntil(String input, int pos, String characters) { - for (; pos < input.length(); pos++) { - if (characters.indexOf(input.charAt(pos)) != -1) { - break; - } - } - return pos; - } - - /** - * Returns the next non-whitespace character in {@code input} that is white space. Result is - * undefined if input contains newline characters. - */ - public static int skipWhitespace(String input, int pos) { - for (; pos < input.length(); pos++) { - char c = input.charAt(pos); - if (c != ' ' && c != '\t') { - break; - } - } - return pos; - } - - /** - * Returns {@code value} as a positive integer, or 0 if it is negative, or {@code defaultValue} if - * it cannot be parsed. - */ - public static int parseSeconds(String value, int defaultValue) { - try { - long seconds = Long.parseLong(value); - if (seconds > Integer.MAX_VALUE) { - return Integer.MAX_VALUE; - } else if (seconds < 0) { - return 0; - } else { - return (int) seconds; - } - } catch (NumberFormatException e) { - return defaultValue; - } - } - - private HeaderParser() { - } -} diff --git a/okhttp/src/main/java/okhttp3/internal/http/Http1xStream.java b/okhttp/src/main/java/okhttp3/internal/http/Http1xStream.java index 42e49d121..e29a91a19 100644 --- a/okhttp/src/main/java/okhttp3/internal/http/Http1xStream.java +++ b/okhttp/src/main/java/okhttp3/internal/http/Http1xStream.java @@ -26,7 +26,8 @@ import okhttp3.Response; import okhttp3.ResponseBody; import okhttp3.internal.Internal; import okhttp3.internal.Util; -import okhttp3.internal.io.RealConnection; +import okhttp3.internal.connection.RealConnection; +import okhttp3.internal.connection.StreamAllocation; import okio.Buffer; import okio.BufferedSink; import okio.BufferedSource; @@ -132,7 +133,7 @@ public final class Http1xStream implements HttpStream { } private Source getTransferStream(Response response) throws IOException { - if (!OkHeaders.hasBody(response)) { + if (!HttpHeaders.hasBody(response)) { return newFixedLengthSource(0); } @@ -140,7 +141,7 @@ public final class Http1xStream implements HttpStream { return newChunkedSource(response.request().url()); } - long contentLength = OkHeaders.contentLength(response); + long contentLength = HttpHeaders.contentLength(response); if (contentLength != -1) { return newFixedLengthSource(contentLength); } @@ -444,7 +445,7 @@ public final class Http1xStream implements HttpStream { } if (bytesRemainingInChunk == 0L) { hasMoreChunks = false; - OkHeaders.receiveHeaders(client.cookieJar(), url, readHeaders()); + HttpHeaders.receiveHeaders(client.cookieJar(), url, readHeaders()); endOfInput(true); } } diff --git a/okhttp/src/main/java/okhttp3/internal/http/Http2xStream.java b/okhttp/src/main/java/okhttp3/internal/http/Http2xStream.java index f5600ce4d..fc989f058 100644 --- a/okhttp/src/main/java/okhttp3/internal/http/Http2xStream.java +++ b/okhttp/src/main/java/okhttp3/internal/http/Http2xStream.java @@ -31,6 +31,7 @@ import okhttp3.Response; import okhttp3.ResponseBody; import okhttp3.internal.Internal; import okhttp3.internal.Util; +import okhttp3.internal.connection.StreamAllocation; import okhttp3.internal.framed.ErrorCode; import okhttp3.internal.framed.FramedConnection; import okhttp3.internal.framed.FramedStream; diff --git a/okhttp/src/main/java/okhttp3/internal/http/OkHeaders.java b/okhttp/src/main/java/okhttp3/internal/http/HttpHeaders.java similarity index 81% rename from okhttp/src/main/java/okhttp3/internal/http/OkHeaders.java rename to okhttp/src/main/java/okhttp3/internal/http/HttpHeaders.java index 486eddb80..5207c996b 100644 --- a/okhttp/src/main/java/okhttp3/internal/http/OkHeaders.java +++ b/okhttp/src/main/java/okhttp3/internal/http/HttpHeaders.java @@ -34,8 +34,8 @@ import static okhttp3.internal.Util.equal; import static okhttp3.internal.http.StatusLine.HTTP_CONTINUE; /** Headers and utilities for internal use by OkHttp. */ -public final class OkHeaders { - private OkHeaders() { +public final class HttpHeaders { + private HttpHeaders() { } public static long contentLength(Request request) { @@ -139,24 +139,7 @@ public final class OkHeaders { return result.build(); } - /** - * Returns true if {@code fieldName} is an end-to-end HTTP header, as defined by RFC 2616, - * 13.5.1. - */ - static boolean isEndToEnd(String fieldName) { - return !"Connection".equalsIgnoreCase(fieldName) - && !"Keep-Alive".equalsIgnoreCase(fieldName) - && !"Proxy-Authenticate".equalsIgnoreCase(fieldName) - && !"Proxy-Authorization".equalsIgnoreCase(fieldName) - && !"TE".equalsIgnoreCase(fieldName) - && !"Trailers".equalsIgnoreCase(fieldName) - && !"Transfer-Encoding".equalsIgnoreCase(fieldName) - && !"Upgrade".equalsIgnoreCase(fieldName); - } - - /** - * Parse RFC 2617 challenges. This API is only interested in the scheme name and realm. - */ + /** Parse RFC 2617 challenges. This API is only interested in the scheme name and realm. */ public static List parseChallenges(Headers responseHeaders, String challengeHeader) { // auth-scheme = token // auth-param = token "=" ( token | quoted-string ) @@ -172,10 +155,10 @@ public final class OkHeaders { int pos = 0; while (pos < value.length()) { int tokenStart = pos; - pos = HeaderParser.skipUntil(value, pos, " "); + pos = skipUntil(value, pos, " "); String scheme = value.substring(tokenStart, pos).trim(); - pos = HeaderParser.skipWhitespace(value, pos); + pos = skipWhitespace(value, pos); // TODO: This currently only handles schemes with a 'realm' parameter; // It needs to be fixed to handle any scheme and any parameters @@ -187,12 +170,12 @@ public final class OkHeaders { pos += "realm=\"".length(); int realmStart = pos; - pos = HeaderParser.skipUntil(value, pos, "\""); + pos = skipUntil(value, pos, "\""); String realm = value.substring(realmStart, pos); pos++; // Consume '"' close quote. - pos = HeaderParser.skipUntil(value, pos, ","); + pos = skipUntil(value, pos, ","); pos++; // Consume ',' comma. - pos = HeaderParser.skipWhitespace(value, pos); + pos = skipWhitespace(value, pos); result.add(new Challenge(scheme, realm)); } } @@ -231,4 +214,50 @@ public final class OkHeaders { return false; } + + /** + * Returns the next index in {@code input} at or after {@code pos} that contains a character from + * {@code characters}. Returns the input length if none of the requested characters can be found. + */ + public static int skipUntil(String input, int pos, String characters) { + for (; pos < input.length(); pos++) { + if (characters.indexOf(input.charAt(pos)) != -1) { + break; + } + } + return pos; + } + + /** + * Returns the next non-whitespace character in {@code input} that is white space. Result is + * undefined if input contains newline characters. + */ + public static int skipWhitespace(String input, int pos) { + for (; pos < input.length(); pos++) { + char c = input.charAt(pos); + if (c != ' ' && c != '\t') { + break; + } + } + return pos; + } + + /** + * Returns {@code value} as a positive integer, or 0 if it is negative, or {@code defaultValue} if + * it cannot be parsed. + */ + public static int parseSeconds(String value, int defaultValue) { + try { + long seconds = Long.parseLong(value); + if (seconds > Integer.MAX_VALUE) { + return Integer.MAX_VALUE; + } else if (seconds < 0) { + return 0; + } else { + return (int) seconds; + } + } catch (NumberFormatException e) { + return defaultValue; + } + } } diff --git a/okhttp/src/main/java/okhttp3/internal/http/RealInterceptorChain.java b/okhttp/src/main/java/okhttp3/internal/http/RealInterceptorChain.java index 38f225a42..28d69aa32 100644 --- a/okhttp/src/main/java/okhttp3/internal/http/RealInterceptorChain.java +++ b/okhttp/src/main/java/okhttp3/internal/http/RealInterceptorChain.java @@ -22,6 +22,7 @@ import okhttp3.HttpUrl; import okhttp3.Interceptor; import okhttp3.Request; import okhttp3.Response; +import okhttp3.internal.connection.StreamAllocation; /** * A concrete interceptor chain that carries the entire interceptor chain: all application diff --git a/okhttp/src/main/java/okhttp3/internal/http/RealResponseBody.java b/okhttp/src/main/java/okhttp3/internal/http/RealResponseBody.java index d66fed988..673189c29 100644 --- a/okhttp/src/main/java/okhttp3/internal/http/RealResponseBody.java +++ b/okhttp/src/main/java/okhttp3/internal/http/RealResponseBody.java @@ -35,7 +35,7 @@ public final class RealResponseBody extends ResponseBody { } @Override public long contentLength() { - return OkHeaders.contentLength(headers); + return HttpHeaders.contentLength(headers); } @Override public BufferedSource source() { diff --git a/okhttp/src/main/java/okhttp3/internal/http/RetryAndFollowUpInterceptor.java b/okhttp/src/main/java/okhttp3/internal/http/RetryAndFollowUpInterceptor.java index b5a6693dc..99cba6037 100644 --- a/okhttp/src/main/java/okhttp3/internal/http/RetryAndFollowUpInterceptor.java +++ b/okhttp/src/main/java/okhttp3/internal/http/RetryAndFollowUpInterceptor.java @@ -35,6 +35,8 @@ import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okhttp3.Route; +import okhttp3.internal.connection.RouteException; +import okhttp3.internal.connection.StreamAllocation; import static java.net.HttpURLConnection.HTTP_CLIENT_TIMEOUT; import static java.net.HttpURLConnection.HTTP_MOVED_PERM; diff --git a/okhttp/src/main/java/okhttp3/internal/AndroidPlatform.java b/okhttp/src/main/java/okhttp3/internal/platform/AndroidPlatform.java similarity index 99% rename from okhttp/src/main/java/okhttp3/internal/AndroidPlatform.java rename to okhttp/src/main/java/okhttp3/internal/platform/AndroidPlatform.java index c0096c6cd..a903f3b6c 100644 --- a/okhttp/src/main/java/okhttp3/internal/AndroidPlatform.java +++ b/okhttp/src/main/java/okhttp3/internal/platform/AndroidPlatform.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal; +package okhttp3.internal.platform; import android.util.Log; import java.io.IOException; @@ -30,6 +30,7 @@ import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.X509TrustManager; import okhttp3.Protocol; +import okhttp3.internal.Util; import okhttp3.internal.tls.CertificateChainCleaner; /** Android 2.3 or better. */ diff --git a/okhttp/src/main/java/okhttp3/internal/Jdk9Platform.java b/okhttp/src/main/java/okhttp3/internal/platform/Jdk9Platform.java similarity index 98% rename from okhttp/src/main/java/okhttp3/internal/Jdk9Platform.java rename to okhttp/src/main/java/okhttp3/internal/platform/Jdk9Platform.java index 1cd04f965..683e5c1cd 100644 --- a/okhttp/src/main/java/okhttp3/internal/Jdk9Platform.java +++ b/okhttp/src/main/java/okhttp3/internal/platform/Jdk9Platform.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal; +package okhttp3.internal.platform; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; diff --git a/okhttp/src/main/java/okhttp3/internal/JdkWithJettyBootPlatform.java b/okhttp/src/main/java/okhttp3/internal/platform/JdkWithJettyBootPlatform.java similarity index 98% rename from okhttp/src/main/java/okhttp3/internal/JdkWithJettyBootPlatform.java rename to okhttp/src/main/java/okhttp3/internal/platform/JdkWithJettyBootPlatform.java index 5e5e5a43f..27947815d 100644 --- a/okhttp/src/main/java/okhttp3/internal/JdkWithJettyBootPlatform.java +++ b/okhttp/src/main/java/okhttp3/internal/platform/JdkWithJettyBootPlatform.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal; +package okhttp3.internal.platform; import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; @@ -22,6 +22,7 @@ import java.lang.reflect.Proxy; import java.util.List; import javax.net.ssl.SSLSocket; import okhttp3.Protocol; +import okhttp3.internal.Util; /** * OpenJDK 7 or OpenJDK 8 with {@code org.mortbay.jetty.alpn/alpn-boot} in the boot class path. diff --git a/okhttp/src/main/java/okhttp3/internal/OptionalMethod.java b/okhttp/src/main/java/okhttp3/internal/platform/OptionalMethod.java similarity index 99% rename from okhttp/src/main/java/okhttp3/internal/OptionalMethod.java rename to okhttp/src/main/java/okhttp3/internal/platform/OptionalMethod.java index 108ec292d..b7b1717b0 100644 --- a/okhttp/src/main/java/okhttp3/internal/OptionalMethod.java +++ b/okhttp/src/main/java/okhttp3/internal/platform/OptionalMethod.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package okhttp3.internal; +package okhttp3.internal.platform; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; diff --git a/okhttp/src/main/java/okhttp3/internal/Platform.java b/okhttp/src/main/java/okhttp3/internal/platform/Platform.java similarity index 99% rename from okhttp/src/main/java/okhttp3/internal/Platform.java rename to okhttp/src/main/java/okhttp3/internal/platform/Platform.java index 1245b6328..1d94c2e69 100644 --- a/okhttp/src/main/java/okhttp3/internal/Platform.java +++ b/okhttp/src/main/java/okhttp3/internal/platform/Platform.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package okhttp3.internal; +package okhttp3.internal.platform; import java.io.IOException; import java.lang.reflect.Field; diff --git a/okhttp/src/main/java/okhttp3/internal/tls/CertificateChainCleaner.java b/okhttp/src/main/java/okhttp3/internal/tls/CertificateChainCleaner.java index 9b7c2e2a3..3e69f2306 100644 --- a/okhttp/src/main/java/okhttp3/internal/tls/CertificateChainCleaner.java +++ b/okhttp/src/main/java/okhttp3/internal/tls/CertificateChainCleaner.java @@ -21,7 +21,7 @@ import java.security.cert.X509Certificate; import java.util.List; import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.X509TrustManager; -import okhttp3.internal.Platform; +import okhttp3.internal.platform.Platform; /** * Computes the effective certificate chain from the raw array returned by Java's built in TLS APIs.