mirror of
https://github.com/square/okhttp.git
synced 2025-07-31 05:04:26 +03:00
Okio upgrade post kotlin (#4814)
Okio 2.2.2 upgrade and adopt kotlin friendly API
This commit is contained in:
@ -17,7 +17,7 @@ package okhttp3.dnsoverhttps
|
||||
|
||||
import okio.Buffer
|
||||
import okio.ByteString
|
||||
import okio.Utf8
|
||||
import okio.utf8Size
|
||||
import java.io.EOFException
|
||||
import java.net.InetAddress
|
||||
import java.net.UnknownHostException
|
||||
@ -47,7 +47,7 @@ object DnsRecordCodec {
|
||||
val nameBuf = Buffer()
|
||||
val labels = host.split('.').dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
for (label in labels) {
|
||||
val utf8ByteCount = Utf8.size(label)
|
||||
val utf8ByteCount = label.utf8Size()
|
||||
if (utf8ByteCount != label.length.toLong()) {
|
||||
throw IllegalArgumentException("non-ascii hostname: $host")
|
||||
}
|
||||
@ -56,7 +56,7 @@ object DnsRecordCodec {
|
||||
}
|
||||
nameBuf.writeByte(0) // end
|
||||
|
||||
nameBuf.copyTo(this, 0, nameBuf.size())
|
||||
nameBuf.copyTo(this, 0, nameBuf.size)
|
||||
writeShort(type)
|
||||
writeShort(1) // CLASS_IN
|
||||
}.readByteString()
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package okhttp3.dnsoverhttps;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
@ -140,7 +141,7 @@ public class DnsOverHttpsTest {
|
||||
fail();
|
||||
} catch (IOException ioe) {
|
||||
assertThat(ioe).hasMessage("google.com");
|
||||
assertThat(ioe.getCause()).isInstanceOf(RuntimeException.class);
|
||||
assertThat(ioe.getCause()).isInstanceOf(EOFException.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user