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

92 lines 2.9 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 \Throwable|null Exception during on_headers (if any)
47 */
48 public $onHeadersException;
49 /**
50 * @var \Exception|null Exception during createResponse (if any)
51 */
52 public $createResponseException;
53 /**
54 * Attach a response to the easy handle based on the received headers.
55 *
56 * @throws \RuntimeException if no headers have been received or the first
57 * header line is invalid.
58 */
59 public function createResponse() : void
60 {
61 [$ver, $status, $reason, $headers] = \YoastSEO_Vendor\GuzzleHttp\Handler\HeaderProcessor::parseHeaders($this->headers);
62 $normalizedKeys = \YoastSEO_Vendor\GuzzleHttp\Utils::normalizeHeaderKeys($headers);
63 if (!empty($this->options['decode_content']) && isset($normalizedKeys['content-encoding'])) {
64 $headers['x-encoded-content-encoding'] = $headers[$normalizedKeys['content-encoding']];
65 unset($headers[$normalizedKeys['content-encoding']]);
66 if (isset($normalizedKeys['content-length'])) {
67 $headers['x-encoded-content-length'] = $headers[$normalizedKeys['content-length']];
68 $bodyLength = (int) $this->sink->getSize();
69 if ($bodyLength) {
70 $headers[$normalizedKeys['content-length']] = $bodyLength;
71 } else {
72 unset($headers[$normalizedKeys['content-length']]);
73 }
74 }
75 }
76 // Attach a response to the easy handle with the parsed headers.
77 $this->response = new \YoastSEO_Vendor\GuzzleHttp\Psr7\Response($status, $headers, $this->sink, $ver, $reason);
78 }
79 /**
80 * @param string $name
81 *
82 * @return void
83 *
84 * @throws \BadMethodCallException
85 */
86 public function __get($name)
87 {
88 $msg = $name === 'handle' ? 'The EasyHandle has been released' : 'Invalid property: ' . $name;
89 throw new \BadMethodCallException($msg);
90 }
91 }
92