PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 9.1.3
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v9.1.3
9.1.3 9.1.2 9.1.1 9.1.0 9.0.3 9.0.2 9.0.1 9.0.0 8.5.79 8.5.78 8.5.77 8.5.76 8.5.75 8.5.74 8.5.73 8.5.72 8.5.71 8.5.70 8.5.69 8.5.68 8.5.35 8.5.36 8.5.37 8.5.38 8.5.39 All 222 releases
← All changes | vendor/posthog/posthog-php/lib/HttpClient.php +10 -26 8.5.379.1.3 View file →
@@ -46,9 +46,9 @@
46 46 int $maximumBackoffDuration = 10000,
47 47 bool $compressRequests = false,
48 48 bool $debug = false,
49 49 ?Closure $errorHandler = null,
50 - int $curlTimeoutMilliseconds = 10000
50 + int $curlTimeoutMilliseconds = 750
51 51 ) {
52 52 $this->host = $host;
53 53 $this->useSsl = $useSsl;
54 54 $this->maximumBackoffDuration = $maximumBackoffDuration;
@@ -61,21 +61,17 @@
61 61 /**
62 62 * @param string $path
63 63 * @param string|null $payload
64 64 * @param array $extraHeaders
65 - * @param array $requestOptions
66 65 * @return HttpResponse
67 66 */
68 - public function sendRequest(string $path, ?string $payload, array $extraHeaders = [], array $requestOptions = []): HttpResponse
67 + public function sendRequest(string $path, ?string $payload, array $extraHeaders = []): HttpResponse
69 68 {
70 69 $protocol = $this->useSsl ? "https://" : "http://";
71 70
72 - $backoff = 100; // Set initial waiting time to 100ms
71 + $backoff = 100; // Set initial waiting time to 100ms
73 72
74 - $shouldRetry = $requestOptions['shouldRetry'] ?? true;
75 - $shouldVerify = $requestOptions['shouldVerify'] ?? true;
76 -
77 - do {
73 + while ($backoff < $this->maximumBackoffDuration) {
78 74 // open connection
79 75 $ch = curl_init();
80 76
81 77 if (null !== $payload) {
@@ -87,23 +83,13 @@
87 83 if ($this->compressRequests) {
88 84 $headers[] = 'Content-Encoding: gzip';
89 85 }
90 86
91 - // check if timeout exists in request options, if not use default
92 - $timeout = $this->curlTimeoutMilliseconds;
93 - if (isset($requestOptions['timeout'])) {
94 - $timeout = $requestOptions['timeout'];
95 - }
96 -
97 87 curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge($headers, $extraHeaders));
98 88 curl_setopt($ch, CURLOPT_URL, $protocol . $this->host . $path);
99 - curl_setopt($ch, CURLOPT_RETURNTRANSFER, $shouldVerify);
100 - curl_setopt($ch, CURLOPT_TIMEOUT_MS, $shouldVerify ? $timeout : 1);
101 - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $timeout);
102 - if (! $shouldVerify) {
103 - curl_setopt($ch, CURLOPT_NOSIGNAL, true);
104 - curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
105 - }
89 + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
90 + curl_setopt($ch, CURLOPT_TIMEOUT_MS, $this->curlTimeoutMilliseconds);
91 + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $this->curlTimeoutMilliseconds);
106 92
107 93 // retry failed requests just once to diminish impact on performance
108 94 $httpResponse = $this->executePost($ch);
109 95 $responseCode = $httpResponse->getResponseCode();
@@ -110,15 +96,13 @@
110 96
111 97 //close connection
112 98 curl_close($ch);
113 99
114 - if ($shouldVerify && 200 != $responseCode) {
100 + if (200 != $responseCode) {
115 101 // log error
116 102 $this->handleError($ch, $responseCode);
117 103
118 - if ($shouldRetry === false) {
119 - break;
120 - } elseif (($responseCode >= 500 && $responseCode <= 600) || 429 == $responseCode) {
104 + if (($responseCode >= 500 && $responseCode <= 600) || 429 == $responseCode) {
121 105 // If status code is greater than 500 and less than 600, it indicates server error
122 106 // Error code 429 indicates rate limited.
123 107 // Retry uploading in these cases.
124 108 usleep($backoff * 1000);
@@ -130,9 +114,9 @@
130 114 }
131 115 } else {
132 116 break; // no error
133 117 }
134 - } while ($shouldRetry && $backoff < $this->maximumBackoffDuration);
118 + }
135 119
136 120 return $httpResponse;
137 121 }
138 122