diff options
-rw-r--r-- | Android.bp | 6 | ||||
-rw-r--r-- | okhttp/src/main/java/com/squareup/okhttp/HttpUrl.java | 16 |
2 files changed, 17 insertions, 5 deletions
@@ -156,6 +156,7 @@ java_library { defaults: ["okhttp_errorprone_defaults"], host_supported: true, apex_available: [ + "//apex_available:platform", "com.android.adservices", "com.android.devicelock", "com.android.extservices", @@ -169,7 +170,6 @@ java_library { srcs: [ "okhttp/src/main/java/**/*.java", "okhttp-urlconnection/src/main/java/**/*.java", - "okio/okio/src/main/java/**/*.java", ":okhttp_version.java", ], @@ -180,6 +180,10 @@ java_library { "okhttp-android-util-log", ], + static_libs: [ + "okio-lib", + ], + installable: true, // Build against a "core_current" as it cannot use "current" as it has to // build in manifests without frameworks/base. diff --git a/okhttp/src/main/java/com/squareup/okhttp/HttpUrl.java b/okhttp/src/main/java/com/squareup/okhttp/HttpUrl.java index e90eb8d..cd174d7 100644 --- a/okhttp/src/main/java/com/squareup/okhttp/HttpUrl.java +++ b/okhttp/src/main/java/com/squareup/okhttp/HttpUrl.java @@ -15,6 +15,7 @@ */ package com.squareup.okhttp; +import java.io.EOFException; import java.net.IDN; import java.net.InetAddress; import java.net.MalformedURLException; @@ -1621,10 +1622,15 @@ public final class HttpUrl { } utf8Buffer.writeUtf8CodePoint(codePoint); while (!utf8Buffer.exhausted()) { - int b = utf8Buffer.readByte() & 0xff; - out.writeByte('%'); - out.writeByte(HEX_DIGITS[(b >> 4) & 0xf]); - out.writeByte(HEX_DIGITS[b & 0xf]); + try { + fakeEofExceptionMethod(); + int b = utf8Buffer.readByte() & 0xff; + out.writeByte('%'); + out.writeByte(HEX_DIGITS[(b >> 4) & 0xf]); + out.writeByte(HEX_DIGITS[b & 0xf]); + } catch (EOFException e) { + throw new IndexOutOfBoundsException(e.getMessage()); + } } } else { // This character doesn't need encoding. Just copy it over. @@ -1633,6 +1639,8 @@ public final class HttpUrl { } } + private static void fakeEofExceptionMethod() throws EOFException {} + static String canonicalize(String input, String encodeSet, boolean alreadyEncoded, boolean strict, boolean plusIsSpace, boolean asciiOnly) { return canonicalize(input, 0, input.length(), |