Skip to content

Commit

Permalink
chore: simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
uncleempty committed Feb 5, 2024
1 parent 9503e1c commit 9ebef12
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions common/http/class.Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,18 @@ public function send(bool $followRedirects = false): common_http_Response
$httpResponse->effectiveUrl = curl_getinfo($curlHandler, CURLINFO_EFFECTIVE_URL);
$httpResponse->responseData = $responseData;

$fullInfo = curl_getinfo($curlHandler);
$redirectUrl = curl_getinfo($curlHandler, CURLINFO_REDIRECT_URL);

//curl_setopt($curlHandler, );
curl_close($curlHandler);

if ($followRedirects && in_array($httpResponse->httpCode, self::REDIRECT_CODES, true)) {
$redirectUrl = $fullInfo['redirectUrl'] ?? '';
if ($redirectUrl) {
$this->url = $redirectUrl;
$httpResponse = $this->send();
}
if (
$followRedirects
&& $redirectUrl
&& in_array($httpResponse->httpCode, self::REDIRECT_CODES, true)
) {
$this->url = $redirectUrl;
$httpResponse = $this->send();
}

return $httpResponse;
Expand Down

0 comments on commit 9ebef12

Please sign in to comment.