From 8acf813443b0502c9ee77379bd968e46894306d9 Mon Sep 17 00:00:00 2001 From: Martijn van der Ven Date: Fri, 4 May 2018 16:24:55 +0200 Subject: [PATCH] Bring back the debug property Rebuild the debug property from the raw headers passed to the new CURLOPT_HEADERFUNCTION and the response body. This will match the raw HTTP response more than previously. It will also contain all the redirecting steps and HTTP status lines. --- src/p3k/HTTP/Curl.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/p3k/HTTP/Curl.php b/src/p3k/HTTP/Curl.php index 8336215..328397d 100644 --- a/src/p3k/HTTP/Curl.php +++ b/src/p3k/HTTP/Curl.php @@ -10,6 +10,7 @@ class Curl implements Transport { private $_last_seen_code = null; private $_current_headers = []; private $_current_redirects = []; + private $_debug_header = ''; public function set_max_redirects($max) { $this->_max_redirects = $max; @@ -32,7 +33,8 @@ class Curl implements Transport { 'redirects' => $this->_current_redirects, 'error' => self::error_string_from_code(curl_errno($ch)), 'error_description' => curl_error($ch), - 'url' => $this->_last_seen_url + 'url' => $this->_last_seen_url, + 'debug' => $this->_debug_header . "\r\n" . $response ]; } @@ -51,7 +53,8 @@ class Curl implements Transport { 'redirects' => $this->_current_redirects, 'error' => self::error_string_from_code(curl_errno($ch)), 'error_description' => curl_error($ch), - 'url' => $this->_last_seen_url + 'url' => $this->_last_seen_url, + 'debug' => $this->_debug_header . "\r\n" . $response ]; } @@ -68,7 +71,8 @@ class Curl implements Transport { 'redirects' => $this->_current_redirects, 'error' => self::error_string_from_code(curl_errno($ch)), 'error_description' => curl_error($ch), - 'url' => $this->_last_seen_url + 'url' => $this->_last_seen_url, + 'debug' => $this->_debug_header . "\r\n" . $response ]; } @@ -96,6 +100,7 @@ class Curl implements Transport { } private function _header_function($curl, $header) { + $this->_debug_header .= $header; $current_url = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL); if ($current_url !== $this->_last_seen_url) { if ($this->_last_seen_url !== null) {