forked from GNUsocial/gnu-social
config['follow_redirects'] is the extlib's config! if max_redirs is set we want to do our own redirection following in this function
This commit is contained in:
parent
a888294135
commit
b1b6a0a69c
@ -321,10 +321,11 @@ class HTTPClient extends HTTP_Request2
|
|||||||
public function send()
|
public function send()
|
||||||
{
|
{
|
||||||
$maxRedirs = intval($this->config['max_redirs']);
|
$maxRedirs = intval($this->config['max_redirs']);
|
||||||
if (empty($this->config['follow_redirects'])) {
|
if (empty($this->config['max_redirs'])) {
|
||||||
$maxRedirs = 0;
|
$maxRedirs = 0;
|
||||||
}
|
}
|
||||||
$redirs = 0;
|
$redirs = 0;
|
||||||
|
$redirUrls = array();
|
||||||
do {
|
do {
|
||||||
try {
|
try {
|
||||||
$response = parent::send();
|
$response = parent::send();
|
||||||
@ -333,9 +334,12 @@ class HTTPClient extends HTTP_Request2
|
|||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
$code = $response->getStatus();
|
$code = $response->getStatus();
|
||||||
|
$effectiveUrl = $response->getEffectiveUrl();
|
||||||
|
$redirUrls[] = $effectiveUrl;
|
||||||
|
$response->redirUrls = $redirUrls;
|
||||||
if ($code >= 200 && $code < 300) {
|
if ($code >= 200 && $code < 300) {
|
||||||
$reason = $response->getReasonPhrase();
|
$reason = $response->getReasonPhrase();
|
||||||
$this->log(LOG_INFO, "$code $reason");
|
$this->log(LOG_INFO, "$code $reason - Effective URL: ".$response->getEffectiveUrl().' – redirect: '.json_encode($response->isRedirect()));
|
||||||
} elseif ($code >= 300 && $code < 400) {
|
} elseif ($code >= 300 && $code < 400) {
|
||||||
$url = $this->getUrl();
|
$url = $this->getUrl();
|
||||||
$target = $response->getHeader('Location');
|
$target = $response->getHeader('Location');
|
||||||
|
Loading…
Reference in New Issue
Block a user