Skip to content

Commit

Permalink
improve logging and handling for content-length header
Browse files Browse the repository at this point in the history
  • Loading branch information
NikkyAI committed Mar 21, 2021
1 parent 2600829 commit 8ea755e
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@ suspend fun File.download(

val headerContentLength = response.headers["content-length"]?.toLong()
if (headerContentLength != null) {
require(contentLength == headerContentLength) {
"received bytes != contentLength: $contentLength != $headerContentLength"
if(contentLength != headerContentLength) {
logger.error { "received bytes != contentLength: $contentLength != $headerContentLength" }
logger.error("waiting for {} ms", retryDelay)
delay(retryDelay)
throw IOException("incorrect response length")
}
} else {
logger.warn { "content-length header missing ?" }
}
}
}
Expand Down

0 comments on commit 8ea755e

Please sign in to comment.