function __construct($url=null, $method=self::METHOD_GET, $config=array())
{
+ $this->config['connect_timeout'] = common_config('http', 'connect_timeout') ?: $this->config['connect_timeout'];
$this->config['max_redirs'] = 10;
$this->config['follow_redirects'] = true;
public function send()
{
$maxRedirs = intval($this->config['max_redirs']);
- if (empty($this->config['follow_redirects'])) {
+ if (empty($this->config['max_redirs'])) {
$maxRedirs = 0;
}
$redirs = 0;
+ $redirUrls = array();
do {
try {
$response = parent::send();
throw $e;
}
$code = $response->getStatus();
+ $effectiveUrl = $response->getEffectiveUrl();
+ $redirUrls[] = $effectiveUrl;
+ $response->redirUrls = $redirUrls;
if ($code >= 200 && $code < 300) {
$reason = $response->getReasonPhrase();
$this->log(LOG_INFO, "$code $reason");
continue;
} catch (HTTP_Request2_Exception $e) {
common_log(LOG_ERR, __CLASS__ . ": Invalid $code redirect from $url to $target");
- } catch (NoHttpResponseException $e) {
- common_log(LOG_ERR, __CLASS__ . ": {$e->getMessage()}");
}
} else {
$reason = $response->getReasonPhrase();