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

97 lines 3.1 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 ResponseInterface|null Received response (if any)
31 */
32 public $response;
33 /**
34 * @var RequestInterface Request being sent
35 */
36 public $request;
37 /**
38 * @var array Request options
39 */
40 public $options = [];
41 /**
42 * @var int cURL error number (if any)
43 */
44 public $errno = 0;
45 /**
46 * @var string|null Effective CURLOPT_PROXY value the handle was created with (if any)
47 */
48 public $effectiveProxy;
49 /**
50 * @var \Throwable|null Exception during on_headers (if any)
51 */
52 public $onHeadersException;
53 /**
54 * @var \Throwable|null Exception during createResponse (if any)
55 */
56 public $createResponseException;
57 /**
58 * Attach a response to the easy handle based on the received headers.
59 *
60 * @throws \RuntimeException if no headers have been received or the first
61 * header line is invalid.
62 */
63 public function createResponse() : void
64 {
65 $this->response = null;
66 [$ver, $status, $reason, $headers] = \YoastSEO_Vendor\GuzzleHttp\Handler\HeaderProcessor::parseHeaders($this->headers);
67 $normalizedKeys = \YoastSEO_Vendor\GuzzleHttp\Utils::normalizeHeaderKeys($headers);
68 if (!empty($this->options['decode_content']) && isset($normalizedKeys['content-encoding'])) {
69 $headers['x-encoded-content-encoding'] = $headers[$normalizedKeys['content-encoding']];
70 unset($headers[$normalizedKeys['content-encoding']]);
71 if (isset($normalizedKeys['content-length'])) {
72 $headers['x-encoded-content-length'] = $headers[$normalizedKeys['content-length']];
73 $bodyLength = (int) $this->sink->getSize();
74 if ($bodyLength) {
75 $headers[$normalizedKeys['content-length']] = [(string) $bodyLength];
76 } else {
77 unset($headers[$normalizedKeys['content-length']]);
78 }
79 }
80 }
81 // Attach a response to the easy handle with the parsed headers.
82 $this->response = new \YoastSEO_Vendor\GuzzleHttp\Psr7\Response($status, $headers, $this->sink, $ver, $reason);
83 }
84 /**
85 * @param string $name
86 *
87 * @return void
88 *
89 * @throws \BadMethodCallException
90 */
91 public function __get($name)
92 {
93 $msg = $name === 'handle' ? 'The EasyHandle has been released' : 'Invalid property: ' . $name;
94 throw new \BadMethodCallException($msg);
95 }
96 }
97