Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F726891
D423.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Jan 6, 2:34 AM
Size
1 KB
Mime Type
text/x-diff
Expires
Tue, Jan 7, 2:34 AM (2 d, 19 h ago)
Engine
blob
Format
Raw Data
Handle
536980
Attached To
D423: INP-1819 - Allow retrieving response headers after making the cURL request
D423.diff
View Options
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
Log In to Comment