PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.4
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.4
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / vendor_prefixed / guzzlehttp / guzzle / src / Handler / EasyHandle.php

EasyHandle.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.4, at vendor_prefixed/guzzlehttp/guzzle/src/Handler/EasyHandle.php

68 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace YoastSEO_Vendor\GuzzleHttp\Handler;
4
5 use YoastSEO_Vendor\GuzzleHttp\Psr7\Response;
6 use YoastSEO_Vendor\Psr\Http\Message\RequestInterface;
7 use YoastSEO_Vendor\Psr\Http\Message\ResponseInterface;
8 use YoastSEO_Vendor\Psr\Http\Message\StreamInterface;
9 /**
10 * Represents a cURL easy handle and the data it populates.
11 *
12 * @internal
13 */
14 final class EasyHandle
15 {
16 /** @var resource cURL resource */
17 public $handle;
18 /** @var StreamInterface Where data is being written */
19 public $sink;
20 /** @var array Received HTTP headers so far */
21 public $headers = [];
22 /** @var ResponseInterface Received response (if any) */
23 public $response;
24 /** @var RequestInterface Request being sent */
25 public $request;
26 /** @var array Request options */
27 public $options = [];
28 /** @var int cURL error number (if any) */
29 public $errno = 0;
30 /** @var \Exception Exception during on_headers (if any) */
31 public $onHeadersException;
32 /**
33 * Attach a response to the easy handle based on the received headers.
34 *
35 * @throws \RuntimeException if no headers have been received.
36 */
37 public function createResponse()
38 {
39 if (empty($this->headers)) {
40 throw new \RuntimeException('No headers have been received');
41 }
42 // HTTP-version SP status-code SP reason-phrase
43 $startLine = \explode(' ', \array_shift($this->headers), 3);
44 $headers = \YoastSEO_Vendor\GuzzleHttp\headers_from_lines($this->headers);
45 $normalizedKeys = \YoastSEO_Vendor\GuzzleHttp\normalize_header_keys($headers);
46 if (!empty($this->options['decode_content']) && isset($normalizedKeys['content-encoding'])) {
47 $headers['x-encoded-content-encoding'] = $headers[$normalizedKeys['content-encoding']];
48 unset($headers[$normalizedKeys['content-encoding']]);
49 if (isset($normalizedKeys['content-length'])) {
50 $headers['x-encoded-content-length'] = $headers[$normalizedKeys['content-length']];
51 $bodyLength = (int) $this->sink->getSize();
52 if ($bodyLength) {
53 $headers[$normalizedKeys['content-length']] = $bodyLength;
54 } else {
55 unset($headers[$normalizedKeys['content-length']]);
56 }
57 }
58 }
59 // Attach a response to the easy handle with the parsed headers.
60 $this->response = new \YoastSEO_Vendor\GuzzleHttp\Psr7\Response($startLine[1], $headers, $this->sink, \substr($startLine[0], 5), isset($startLine[2]) ? (string) $startLine[2] : null);
61 }
62 public function __get($name)
63 {
64 $msg = $name === 'handle' ? 'The EasyHandle has been released' : 'Invalid property: ' . $name;
65 throw new \BadMethodCallException($msg);
66 }
67 }
68