Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions requests/src/requests/Requester.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package requests

import requests.Requester.methodField
Copy link
Member

@lolgab lolgab Dec 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a spurious change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, will remove


import java.io.{ByteArrayInputStream, ByteArrayOutputStream, OutputStream}
import java.net.{HttpCookie, HttpURLConnection, InetSocketAddress}
import java.util.zip.{GZIPInputStream, InflaterInputStream}

import javax.net.ssl._

import collection.JavaConverters._
import scala.collection.mutable

Expand Down Expand Up @@ -283,7 +283,6 @@ case class Requester(verb: String,

val deGzip = autoDecompress && headerFields.get("content-encoding").toSeq.flatten.exists(_.contains("gzip"))
val deDeflate = autoDecompress && headerFields.get("content-encoding").toSeq.flatten.exists(_.contains("deflate"))

def persistCookies() = {
if (sess.persistCookies) {
headerFields
Expand Down Expand Up @@ -333,7 +332,11 @@ case class Requester(verb: String,
else connection.getErrorStream

def processWrappedStream[V](f: java.io.InputStream => V): V = {
if (stream != null) {
// The HEAD method is identical to GET except that the server
// MUST NOT return a message-body in the response.
// https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html section 9.4
if (verb == "HEAD") f(new ByteArrayInputStream(Array()))
else if (stream != null) {
try f(
if (deGzip) new GZIPInputStream(stream)
else if (deDeflate) new InflaterInputStream(stream)
Expand Down
8 changes: 8 additions & 0 deletions requests/test/src/requests/RequestTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -260,5 +260,13 @@ object RequestTests extends TestSuite{
)
assert(res.statusCode == 200)
}
test("gzipError"){
val response = requests.head("https://api.github.com/users/lihaoyi")
assert(response.statusCode == 200)
assert(response.statusMessage == "OK")
assert(response.data.array.isEmpty)
assert(response.headers.keySet.contains("content-length"))
assert(response.headers.keySet.contains("content-type"))
}
}
}