mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-30 12:14:36 +00:00
Add additional request details in Curl::diagnose()
This commit is contained in:
+18
-4
@@ -1474,6 +1474,12 @@ class Curl
|
||||
|
||||
echo 'Request contained ' . ($request_body_empty ? 'no body' : 'a body') . '.' . "\n";
|
||||
|
||||
if ($this->getOpt(CURLOPT_VERBOSE) || $this->getOpt(CURLINFO_HEADER_OUT) !== true) {
|
||||
echo
|
||||
'Warning: Request headers (Curl::requestHeaders) are expected be empty ' .
|
||||
'(CURLOPT_VERBOSE was enabled or CURLINFO_HEADER_OUT was disabled).' . "\n";
|
||||
}
|
||||
|
||||
echo
|
||||
'Received response containing ' . (
|
||||
$response_headers_count === 0 ? 'no headers.' :
|
||||
@@ -1487,6 +1493,14 @@ class Curl
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($this->responseHeaders['Content-Type'])) {
|
||||
echo 'Response did not set a content type' . "\n";
|
||||
} elseif (preg_match($this->jsonPattern, $this->responseHeaders['Content-Type'])) {
|
||||
echo 'Response appears to be JSON' . "\n";
|
||||
} elseif (preg_match($this->xmlPattern, $this->responseHeaders['Content-Type'])) {
|
||||
echo 'Response appears to be XML' . "\n";
|
||||
}
|
||||
|
||||
if ($this->curlError) {
|
||||
echo
|
||||
'A curl error (' . $this->curlErrorCode . ') occurred ' .
|
||||
@@ -1501,10 +1515,10 @@ class Curl
|
||||
'with message "' . $this->httpErrorMessage . '".' . "\n";
|
||||
}
|
||||
|
||||
if ($this->response === null) {
|
||||
echo 'Received no response body.' . "\n";
|
||||
} elseif ($this->response === '') {
|
||||
echo 'Received an empty response body.' . "\n";
|
||||
if ($this->rawResponse === null) {
|
||||
echo 'Received no response body (response=null).' . "\n";
|
||||
} elseif ($this->rawResponse === '') {
|
||||
echo 'Received an empty response body (response="").' . "\n";
|
||||
} else {
|
||||
echo 'Received a non-empty response body.' . "\n";
|
||||
echo 'Response content length: ' . $response_length . "\n";
|
||||
|
||||
Reference in New Issue
Block a user