{"action":"created","issue":{"url":"https://api.github.com/repos/sbt/librarymanagement/issues/180","repository_url":"https://api.github.com/repos/sbt/librarymanagement","labels_url":"https://api.github.com/repos/sbt/librarymanagement/issues/180/labels{/name}","comments_url":"https://api.github.com/repos/sbt/librarymanagement/issues/180/comments","events_url":"https://api.github.com/repos/sbt/librarymanagement/issues/180/events","html_url":"https://github.com/sbt/librarymanagement/issues/180","id":271511913,"number":180,"title":"NullPointerException in GigahorseUrlHandler : 54 (Content Type null)","user":{"login":"TeofilisMartisius","id":8331155,"avatar_url":"https://avatars1.githubusercontent.com/u/8331155?v=4","gravatar_id":"","url":"https://api.github.com/users/TeofilisMartisius","html_url":"https://github.com/TeofilisMartisius","followers_url":"https://api.github.com/users/TeofilisMartisius/followers","following_url":"https://api.github.com/users/TeofilisMartisius/following{/other_user}","gists_url":"https://api.github.com/users/TeofilisMartisius/gists{/gist_id}","starred_url":"https://api.github.com/users/TeofilisMartisius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TeofilisMartisius/subscriptions","organizations_url":"https://api.github.com/users/TeofilisMartisius/orgs","repos_url":"https://api.github.com/users/TeofilisMartisius/repos","events_url":"https://api.github.com/users/TeofilisMartisius/events{/privacy}","received_events_url":"https://api.github.com/users/TeofilisMartisius/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-11-06T15:21:28Z","updated_at":"2018-02-27T12:37:52Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nSBT version 1.0.2.\r\n\r\nI'm getting NullPointerExceptions in GigahorseUrlHandler.scala line 54:\r\n\r\n```\r\n            BasicURLHandler.getCharSetFromContentType(response.body().contentType().toString)\r\n```\r\n\r\nIt assumes that content type will ALWAYS be present. However, when performing HEAD requests, okhttp does NOT give content Type information, contentType is null. To try it, you can run this to verify:\r\n\r\n```\r\nimport java.net.URL\r\nimport okhttp3.{OkHttpClient, Request}\r\n\r\nobject test {\r\n  def main(args: Array[String]) = {\r\n    val okHttpClient = new OkHttpClient()\r\n\r\n    val url = new URL(\"http://your.url.com/\");\r\n\r\n    val head = new Request.Builder().url(url).head()\r\n    val responseHead = okHttpClient.newCall(head.build()).execute()\r\n    // Will be null\r\n    println(\"Content Type for HEAD =\" + responseHead.body().contentType())\r\n\r\n    val get = new Request.Builder().url(url).get()\r\n    val responseGet = okHttpClient.newCall(get.build()).execute()\r\n    println(\"Content Type for GET =\" + responseGet.body().contentType())\r\n  }\r\n}\r\n```\r\n\r\nSincerely,\r\nTeofilis Martisius"},"comment":{"url":"https://api.github.com/repos/sbt/librarymanagement/issues/comments/368860086","html_url":"https://github.com/sbt/librarymanagement/issues/180#issuecomment-368860086","issue_url":"https://api.github.com/repos/sbt/librarymanagement/issues/180","id":368860086,"user":{"login":"dhoepelman","id":992153,"avatar_url":"https://avatars0.githubusercontent.com/u/992153?v=4","gravatar_id":"","url":"https://api.github.com/users/dhoepelman","html_url":"https://github.com/dhoepelman","followers_url":"https://api.github.com/users/dhoepelman/followers","following_url":"https://api.github.com/users/dhoepelman/following{/other_user}","gists_url":"https://api.github.com/users/dhoepelman/gists{/gist_id}","starred_url":"https://api.github.com/users/dhoepelman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhoepelman/subscriptions","organizations_url":"https://api.github.com/users/dhoepelman/orgs","repos_url":"https://api.github.com/users/dhoepelman/repos","events_url":"https://api.github.com/users/dhoepelman/events{/privacy}","received_events_url":"https://api.github.com/users/dhoepelman/received_events","type":"User","site_admin":false},"created_at":"2018-02-27T12:37:52Z","updated_at":"2018-02-27T12:37:52Z","author_association":"NONE","body":"We encountered the same problem with the osgeo Geotools repository (e.g. [this pom](https://download.osgeo.org/webdav/geotools/org/geotools/gt-api/18.2/gt-api-18.2.pom)), so there definitely are servers in the wild that don't return a content-type for `.pom` files."}}
{"actor":{"display_login":"dhoepelman"}}