Skip to content

Commit

Permalink
No longer creating a sink when sending HEAD requests
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdowling committed Jul 1, 2016
1 parent a243357 commit 072383b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Handler/StreamHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ private function createResponse(
$headers = \GuzzleHttp\headers_from_lines($hdrs);
list ($stream, $headers) = $this->checkDecode($options, $headers, $stream);
$stream = Psr7\stream_for($stream);
$sink = $this->createSink($stream, $options);
$sink = $stream;

$hasResponseBody = strcasecmp("HEAD", $request->getMethod());
if ($hasResponseBody) {
$sink = $this->createSink($stream, $options);
}

$response = new Psr7\Response($status, $headers, $sink, $ver, $reason);

if (isset($options['on_headers'])) {
Expand All @@ -120,7 +126,7 @@ private function createResponse(

// Do not drain when the request is a HEAD request because they have
// no body.
if ($sink !== $stream && strcasecmp('HEAD', $request->getMethod())) {
if ($hasResponseBody && $sink !== $stream) {
$this->drain(
$stream,
$sink,
Expand Down

0 comments on commit 072383b

Please sign in to comment.