- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/classes/general/http.php
- Класс: CHTTP
- Вызов: CHTTP::HTTPQuery
public function HTTPQuery($method, $url, $postdata = '')
{
if(is_resource($this->fp))
$file_pos = ftell($this->fp);
$this->redirectsMade = 0;
while (true)
{
$this->url = $url;
$arUrl = $this->ParseURL($url);
if (!$this->Query($method, $arUrl['host'], $arUrl['port'], $arUrl['path_query'], $postdata, $arUrl['proto']))
{
return false;
}
if(
$this->follow_redirect
&& isset($this->headers['Location'])
&& $this->headers['Location'] <> ''
)
{
$url = $this->headers['Location'];
if($this->redirectsMade < $this->redirectMax)
{
//When writing to file we have to discard
//redirect body
if(is_resource($this->fp))
{
/** @noinspection PhpUndefinedVariableInspection */
ftruncate($this->fp, $file_pos);
fseek($this->fp, $file_pos, SEEK_SET);
}
$this->redirectsMade++;
continue;
}
else
{
trigger_error("Maximum number of redirects (".$this->redirectMax.") has been reached at URL ".$url, E_USER_WARNING);
return false;
}
}
else
{
break;
}
}
return true;
}