Fix to issue #180 to handle null contentType

If the content type is null, the call for .toString on it will cause an NPE. This fixes this issue by wrapping the call in an Option, then mapping toString or falling back to null. getCharSetFromContentType handles null by returning ISO-8859-1
This commit is contained in:
Ståle Undheim 2018-02-24 00:25:34 +01:00 committed by GitHub
parent 69fb352fa1
commit 42e23e54ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -51,7 +51,7 @@ class GigahorseUrlHandler extends AbstractURLHandler {
if (checkStatusCode(url, response)) {
val bodyCharset =
BasicURLHandler.getCharSetFromContentType(response.body().contentType().toString)
BasicURLHandler.getCharSetFromContentType(Option(response.body().contentType()).map(_.toString).orNull)
Some(
new SbtUrlInfo(true,
response.body().contentLength(),