Update to Drupal 8.1.7. For more information, see https://www.drupal.org/project/drupal/releases/8.1.7

This commit is contained in:
Pantheon Automation 2016-07-18 09:07:48 -07:00 committed by Greg Anderson
parent 38ba7c357d
commit e9f047ccf8
61 changed files with 1613 additions and 561 deletions

View file

@ -194,7 +194,7 @@ class CurlFactory implements CurlFactoryInterface
$conf = [
'_headers' => $easy->request->getHeaders(),
CURLOPT_CUSTOMREQUEST => $easy->request->getMethod(),
CURLOPT_URL => (string) $easy->request->getUri(),
CURLOPT_URL => (string) $easy->request->getUri()->withFragment(''),
CURLOPT_RETURNTRANSFER => false,
CURLOPT_HEADER => false,
CURLOPT_CONNECTTIMEOUT => 150,
@ -265,6 +265,9 @@ class CurlFactory implements CurlFactoryInterface
$this->removeHeader('Content-Length', $conf);
}
$body = $request->getBody();
if ($body->isSeekable()) {
$body->rewind();
}
$conf[CURLOPT_READFUNCTION] = function ($ch, $fd, $length) use ($body) {
return $body->read($length);
};
@ -492,12 +495,14 @@ class CurlFactory implements CurlFactoryInterface
private function createHeaderFn(EasyHandle $easy)
{
if (!isset($easy->options['on_headers'])) {
$onHeaders = null;
} elseif (!is_callable($easy->options['on_headers'])) {
throw new \InvalidArgumentException('on_headers must be callable');
} else {
if (isset($easy->options['on_headers'])) {
$onHeaders = $easy->options['on_headers'];
if (!is_callable($onHeaders)) {
throw new \InvalidArgumentException('on_headers must be callable');
}
} else {
$onHeaders = null;
}
return function ($ch, $h) use (
@ -509,7 +514,7 @@ class CurlFactory implements CurlFactoryInterface
if ($value === '') {
$startingResponse = true;
$easy->createResponse();
if ($onHeaders) {
if ($onHeaders !== null) {
try {
$onHeaders($easy->response);
} catch (\Exception $e) {

View file

@ -192,6 +192,6 @@ class CurlMultiHandler
}
}
return max(0, $currentTime - $nextTime);
return max(0, $nextTime - $currentTime) * 1000000;
}
}

View file

@ -56,8 +56,13 @@ final class EasyHandle
if (!empty($this->options['decode_content'])
&& isset($normalizedKeys['content-encoding'])
) {
$headers['x-encoded-content-encoding']
= $headers[$normalizedKeys['content-encoding']];
unset($headers[$normalizedKeys['content-encoding']]);
if (isset($normalizedKeys['content-length'])) {
$headers['x-encoded-content-length']
= $headers[$normalizedKeys['content-length']];
$bodyLength = (int) $this->sink->getSize();
if ($bodyLength) {
$headers[$normalizedKeys['content-length']] = $bodyLength;

View file

@ -27,7 +27,7 @@ class MockHandler implements \Countable
* @param callable $onFulfilled Callback to invoke when the return value is fulfilled.
* @param callable $onRejected Callback to invoke when the return value is rejected.
*
* @return MockHandler
* @return HandlerStack
*/
public static function createWithMiddleware(
array $queue = null,
@ -74,7 +74,7 @@ class MockHandler implements \Countable
$response = array_shift($this->queue);
if (is_callable($response)) {
$response = $response($request, $options);
$response = call_user_func($response, $request, $options);
}
$response = $response instanceof \Exception
@ -87,6 +87,19 @@ class MockHandler implements \Countable
if ($this->onFulfilled) {
call_user_func($this->onFulfilled, $value);
}
if (isset($options['sink'])) {
$contents = (string) $value->getBody();
$sink = $options['sink'];
if (is_resource($sink)) {
fwrite($sink, $contents);
} elseif (is_string($sink)) {
file_put_contents($sink, $contents);
} elseif ($sink instanceof \Psr\Http\Message\StreamInterface) {
$sink->write($contents);
}
}
return $value;
},
function ($reason) use ($request, $options) {

View file

@ -1,6 +1,7 @@
<?php
namespace GuzzleHttp\Handler;
use GuzzleHttp\RequestOptions;
use Psr\Http\Message\RequestInterface;
/**
@ -22,7 +23,7 @@ class Proxy
callable $sync
) {
return function (RequestInterface $request, array $options) use ($default, $sync) {
return empty($options['sync'])
return empty($options[RequestOptions::SYNCHRONOUS])
? $default($request, $options)
: $sync($request, $options);
};

View file

@ -105,7 +105,12 @@ class StreamHandler
$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;
if (strcasecmp('HEAD', $request->getMethod())) {
$sink = $this->createSink($stream, $options);
}
$response = new Psr7\Response($status, $headers, $sink, $ver, $reason);
if (isset($options['on_headers'])) {
@ -118,8 +123,14 @@ class StreamHandler
}
}
// Do not drain when the request is a HEAD request because they have
// no body.
if ($sink !== $stream) {
$this->drain($stream, $sink);
$this->drain(
$stream,
$sink,
$response->getHeaderLine('Content-Length')
);
}
$this->invokeStats($options, $request, $startTime, $response, null);
@ -138,7 +149,7 @@ class StreamHandler
: fopen('php://temp', 'r+');
return is_string($sink)
? new Psr7\Stream(Psr7\try_fopen($sink, 'r+'))
? new Psr7\LazyOpenStream($sink, 'w+')
: Psr7\stream_for($sink);
}
@ -149,16 +160,21 @@ class StreamHandler
$normalizedKeys = \GuzzleHttp\normalize_header_keys($headers);
if (isset($normalizedKeys['content-encoding'])) {
$encoding = $headers[$normalizedKeys['content-encoding']];
if ($encoding[0] == 'gzip' || $encoding[0] == 'deflate') {
if ($encoding[0] === 'gzip' || $encoding[0] === 'deflate') {
$stream = new Psr7\InflateStream(
Psr7\stream_for($stream)
);
$headers['x-encoded-content-encoding']
= $headers[$normalizedKeys['content-encoding']];
// Remove content-encoding header
unset($headers[$normalizedKeys['content-encoding']]);
// Fix content-length header
if (isset($normalizedKeys['content-length'])) {
$headers['x-encoded-content-length']
= $headers[$normalizedKeys['content-length']];
$length = (int) $stream->getSize();
if ($length == 0) {
if ($length === 0) {
unset($headers[$normalizedKeys['content-length']]);
} else {
$headers[$normalizedKeys['content-length']] = [$length];
@ -176,13 +192,27 @@ class StreamHandler
*
* @param StreamInterface $source
* @param StreamInterface $sink
* @param string $contentLength Header specifying the amount of
* data to read.
*
* @return StreamInterface
* @throws \RuntimeException when the sink option is invalid.
*/
private function drain(StreamInterface $source, StreamInterface $sink)
{
Psr7\copy_to_stream($source, $sink);
private function drain(
StreamInterface $source,
StreamInterface $sink,
$contentLength
) {
// If a content-length header is provided, then stop reading once
// that number of bytes has been read. This can prevent infinitely
// reading from a stream when dealing with servers that do not honor
// Connection: Close headers.
Psr7\copy_to_stream(
$source,
$sink,
strlen($contentLength) > 0 ? (int) $contentLength : -1
);
$sink->seek(0);
$source->close();
@ -279,7 +309,7 @@ class StreamHandler
return $this->createResource(
function () use ($request, &$http_response_header, $context) {
$resource = fopen($request->getUri(), 'r', null, $context);
$resource = fopen((string) $request->getUri()->withFragment(''), 'r', null, $context);
$this->lastHeaders = $http_response_header;
return $resource;
}
@ -341,7 +371,9 @@ class StreamHandler
private function add_timeout(RequestInterface $request, &$options, $value, &$params)
{
$options['http']['timeout'] = $value;
if ($value > 0) {
$options['http']['timeout'] = $value;
}
}
private function add_verify(RequestInterface $request, &$options, $value, &$params)
@ -359,12 +391,14 @@ class StreamHandler
}
} elseif ($value === false) {
$options['ssl']['verify_peer'] = false;
$options['ssl']['verify_peer_name'] = false;
return;
} else {
throw new \InvalidArgumentException('Invalid verify request option');
}
$options['ssl']['verify_peer'] = true;
$options['ssl']['verify_peer_name'] = true;
$options['ssl']['allow_self_signed'] = false;
}
@ -416,7 +450,7 @@ class StreamHandler
'bytes_transferred', 'bytes_max'];
$value = \GuzzleHttp\debug_resource($value);
$ident = $request->getMethod() . ' ' . $request->getUri();
$ident = $request->getMethod() . ' ' . $request->getUri()->withFragment('');
$this->addNotification(
$params,
function () use ($ident, $value, $map, $args) {