Page MenuHomeIn-Portal Phabricator

D278.id1078.diff
No OneTemporary

File Metadata

Created
Wed, Feb 26, 8:59 AM

D278.id1078.diff

Index: core/units/helpers/curl_helper.php
===================================================================
--- core/units/helpers/curl_helper.php
+++ core/units/helpers/curl_helper.php
@@ -148,6 +148,11 @@
parent::__construct();
$this->debugMode = kUtil::constOn('DBG_CURL');
+
+ // Happens, when cURL binding version is below v7.18.2.
+ if ( !defined('CURLINFO_REDIRECT_URL') ) {
+ define('CURLINFO_REDIRECT_URL', 1048607);
+ }
}
/**
@@ -227,7 +232,7 @@
$default_options[CURLOPT_POSTFIELDS] = $this->requestData;
}
-// $default_options[CURLOPT_HEADERFUNCTION] = Array(&$this, 'ParseHeader');
+ $default_options[CURLOPT_HEADERFUNCTION] = array(&$this, 'ParseHeader');
$user_options = $this->options; // backup options, that user set directly
$this->setOptions($default_options);
@@ -494,6 +499,20 @@
return $this->lastRedirectCount;
}
+ if ( $info_type == CURLINFO_REDIRECT_URL ) {
+ if ( $this->followLocation ) {
+ return '';
+ }
+
+ foreach ( $this->responseHeaders as $header ) {
+ if ( preg_match('/^location: (.*)$/i', $header, $matches) ) {
+ return $matches[1];
+ }
+ }
+
+ return '';
+ }
+
return curl_getinfo($this->connectionID, $info_type);
}
@@ -570,4 +589,4 @@
return ($this->lastHTTPCode == 200) || ($this->lastHTTPCode >= 300 && $this->lastHTTPCode < 310);
}
- }
\ No newline at end of file
+ }

Event Timeline