From baf93110dbe27f4b4e95f174230a364b0c621660 Mon Sep 17 00:00:00 2001 From: Tonyo Francis Date: Mon, 17 Aug 2020 08:32:24 -0400 Subject: [PATCH] okhttp fixes --- .../com/tonyodev/fetch2okhttp/OkHttpDownloader.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fetch2okhttp/src/main/java/com/tonyodev/fetch2okhttp/OkHttpDownloader.kt b/fetch2okhttp/src/main/java/com/tonyodev/fetch2okhttp/OkHttpDownloader.kt index f84b77e9..206cebd7 100644 --- a/fetch2okhttp/src/main/java/com/tonyodev/fetch2okhttp/OkHttpDownloader.kt +++ b/fetch2okhttp/src/main/java/com/tonyodev/fetch2okhttp/OkHttpDownloader.kt @@ -74,8 +74,8 @@ open class OkHttpDownloader @JvmOverloads constructor( .build() } var okHttpResponse = client.newCall(okHttpRequest).execute() - var responseHeaders = okHttpResponse.headers().toMultimap() - var code = okHttpResponse.code() + var responseHeaders = okHttpResponse.headers.toMultimap() + var code = okHttpResponse.code if ((code == HttpURLConnection.HTTP_MOVED_TEMP || code == HttpURLConnection.HTTP_MOVED_PERM || code == HttpURLConnection.HTTP_SEE_OTHER) && getHeaderValue(responseHeaders, "Location") != null) { @@ -88,20 +88,20 @@ open class OkHttpDownloader @JvmOverloads constructor( .build() } okHttpResponse = client.newCall(okHttpRequest).execute() - responseHeaders = okHttpResponse.headers().toMultimap() - code = okHttpResponse.code() + responseHeaders = okHttpResponse.headers.toMultimap() + code = okHttpResponse.code } val success = okHttpResponse.isSuccessful val contentLength = getContentLengthFromHeader(responseHeaders, -1L) - val byteStream: InputStream? = okHttpResponse.body()?.byteStream() + val byteStream: InputStream? = okHttpResponse.body?.byteStream() val errorResponseString: String? = if (!success) { copyStreamToString(byteStream, false) } else { null } - val hash = getContentHash(responseHeaders) + val hash = getContentHash(responseHeaders.toMutableMap()) val acceptsRanges = acceptRanges(code, responseHeaders)