@@ -3,9 +3,7 @@ package requests
3
3
import java .io .{ByteArrayInputStream , ByteArrayOutputStream , OutputStream }
4
4
import java .net .{HttpCookie , HttpURLConnection , InetSocketAddress }
5
5
import java .util .zip .{GZIPInputStream , InflaterInputStream }
6
-
7
6
import javax .net .ssl ._
8
-
9
7
import collection .JavaConverters ._
10
8
import scala .collection .mutable
11
9
@@ -283,7 +281,6 @@ case class Requester(verb: String,
283
281
284
282
val deGzip = autoDecompress && headerFields.get(" content-encoding" ).toSeq.flatten.exists(_.contains(" gzip" ))
285
283
val deDeflate = autoDecompress && headerFields.get(" content-encoding" ).toSeq.flatten.exists(_.contains(" deflate" ))
286
-
287
284
def persistCookies () = {
288
285
if (sess.persistCookies) {
289
286
headerFields
@@ -333,7 +330,11 @@ case class Requester(verb: String,
333
330
else connection.getErrorStream
334
331
335
332
def processWrappedStream [V ](f : java.io.InputStream => V ): V = {
336
- if (stream != null ) {
333
+ // The HEAD method is identical to GET except that the server
334
+ // MUST NOT return a message-body in the response.
335
+ // https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html section 9.4
336
+ if (verb == " HEAD" ) f(new ByteArrayInputStream (Array ()))
337
+ else if (stream != null ) {
337
338
try f(
338
339
if (deGzip) new GZIPInputStream (stream)
339
340
else if (deDeflate) new InflaterInputStream (stream)
0 commit comments