PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.5
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 28.5, at vendor_prefixed/guzzlehttp/guzzle/src/Handler/EasyHandle.php

113 lines 3.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\GuzzleHttp\Utils;
7 use YoastSEO_Vendor\Psr\Http\Message\RequestInterface;
8 use YoastSEO_Vendor\Psr\Http\Message\ResponseInterface;
9 use YoastSEO_Vendor\Psr\Http\Message\StreamInterface;
10 /**
11 * Represents a cURL easy handle and the data it populates.
12 *
13 * @internal
14 */
15 final class EasyHandle
16 {
17 /**
18 * @var resource|\CurlHandle cURL resource
19 */
20 public $handle;
21 /**
22 * @var StreamInterface Where data is being written
23 */
24 public $sink;
25 /**
26 * @var array Received HTTP headers so far
27 */
28 public $headers = [];
29 /**
30 * @var array Valid trailer lines, retained only when an on_trailers
31 * callback is configured
32 */
33 public $trailers = [];
34 /**
35 * @var bool Whether this handle was configured with CURLOPT_PIPEWAIT
36 */
37 public $usesPipewait = \false;
38 /**
39 * @var ResponseInterface|null Received response (if any)
40 */
41 public $response;
42 /**
43 * @var RequestInterface Request being sent
44 */
45 public $request;
46 /**
47 * @var array Request options
48 */
49 public $options = [];
50 /**
51 * @var int cURL error number (if any)
52 */
53 public $errno = 0;
54 /**
55 * @var string|null Effective CURLOPT_PROXY value the handle was created with (if any)
56 */
57 public $effectiveProxy;
58 /**
59 * Proxy tunnel or SOCKS proxy section signature for connection-reuse
60 * isolation, or null when the request does not require sectioning.
61 *
62 * @var string|null
63 */
64 public $proxyTunnelSignature;
65 /**
66 * @var \Throwable|null Exception during on_headers (if any)
67 */
68 public $onHeadersException;
69 /**
70 * @var \Throwable|null Exception during createResponse (if any)
71 */
72 public $createResponseException;
73 /**
74 * Attach a response to the easy handle based on the received headers.
75 *
76 * @throws \RuntimeException if no headers have been received or the first
77 * header line is invalid.
78 */
79 public function createResponse() : void
80 {
81 $this->response = null;
82 [$ver, $status, $reason, $headers] = \YoastSEO_Vendor\GuzzleHttp\Handler\HeaderProcessor::parseHeaders($this->headers);
83 $normalizedKeys = \YoastSEO_Vendor\GuzzleHttp\Utils::normalizeHeaderKeys($headers);
84 if (isset($this->options['decode_content']) && $this->options['decode_content'] !== \false && isset($normalizedKeys['content-encoding'])) {
85 $headers['x-encoded-content-encoding'] = $headers[$normalizedKeys['content-encoding']];
86 unset($headers[$normalizedKeys['content-encoding']]);
87 if (isset($normalizedKeys['content-length'])) {
88 $headers['x-encoded-content-length'] = $headers[$normalizedKeys['content-length']];
89 $bodyLength = (int) $this->sink->getSize();
90 if ($bodyLength) {
91 $headers[$normalizedKeys['content-length']] = [(string) $bodyLength];
92 } else {
93 unset($headers[$normalizedKeys['content-length']]);
94 }
95 }
96 }
97 // Attach a response to the easy handle with the parsed headers.
98 $this->response = new \YoastSEO_Vendor\GuzzleHttp\Psr7\Response($status, $headers, $this->sink, $ver, $reason);
99 }
100 /**
101 * @param string $name
102 *
103 * @return void
104 *
105 * @throws \BadMethodCallException
106 */
107 public function __get($name)
108 {
109 $msg = $name === 'handle' ? 'The EasyHandle has been released' : 'Invalid property: ' . $name;
110 throw new \BadMethodCallException($msg);
111 }
112 }
113