Page MenuHomeIn-Portal Phabricator

D423.diff
No OneTemporary

File Metadata

Created
Mon, Jan 6, 2:34 AM

D423.diff

Index: branches/5.2.x/core/units/helpers/curl_helper.php
===================================================================
--- branches/5.2.x/core/units/helpers/curl_helper.php
+++ branches/5.2.x/core/units/helpers/curl_helper.php
@@ -162,6 +162,7 @@
$this->requestMethod = self::REQUEST_METHOD_GET;
$this->requestData = '';
$this->requestHeaders = Array ();
+ $this->responseHeaders = Array ();
$this->options = Array ();
}
@@ -227,7 +228,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);
@@ -257,7 +258,11 @@
*/
protected function ParseHeader(&$ch, $header)
{
- $this->responseHeaders[] = $header;
+ $trimmed_header = rtrim($header);
+
+ if ( $trimmed_header ) {
+ $this->responseHeaders[] = $trimmed_header;
+ }
return strlen($header);
}
@@ -392,8 +397,6 @@
$this->logId = $this->Conn->getInsertID();
}
- $this->responseHeaders = Array ();
-
$this->prepareOptions();
$this->lastResponse = $this->_sendRequest();
@@ -498,6 +501,16 @@
}
/**
+ * Returns response headers.
+ *
+ * @return array
+ */
+ public function getResponseHeaders()
+ {
+ return $this->responseHeaders;
+ }
+
+ /**
* Detects, that follow location can't be done automatically by curl due safe_mode/open_basedir restrictions
*
* @return bool
@@ -570,4 +583,4 @@
return ($this->lastHTTPCode == 200) || ($this->lastHTTPCode >= 300 && $this->lastHTTPCode < 310);
}
- }
\ No newline at end of file
+ }

Event Timeline