softwaremill / sttp

The Scala HTTP client you always wanted!
https://sttp.softwaremill.com
Apache License 2.0
1.44k stars 301 forks source link

HEAD requests that have Content-Type of gzip fail every time #224

Closed swartzrock closed 5 years ago

swartzrock commented 5 years ago

Try this out with 1.5.19:

val req = sttp.head(uri"https://www.google.com")
implicit val backend = HttpURLConnectionBackend()
req.send()

You'll see this failure:

java.io.EOFException
    at java.util.zip.GZIPInputStream.readUByte(GZIPInputStream.java:268)
    at java.util.zip.GZIPInputStream.readUShort(GZIPInputStream.java:258)
    at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:164)
    at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:79)
    at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:91)
    at com.softwaremill.sttp.HttpURLConnectionBackend.wrapInput(HttpURLConnectionBackend.scala:283)

Apparently the GZIPInputStream is created despite the lack of a response body, immediately causing a failure.

It would be great if there was a way to stop sttp from creating the GZIPInputStream so I could ignore the body.

adamw commented 5 years ago

Should be fixed in 1.6.0: https://github.com/softwaremill/sttp/releases/tag/v1.6.0