mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-30 04:01:47 +00:00
Format response header type notice as sentence
This commit is contained in:
+4
-4
@@ -1294,7 +1294,7 @@ class Curl extends BaseCurl
|
||||
|
||||
if ($request_headers_count === 0 && (
|
||||
$this->getOpt(CURLOPT_VERBOSE) ||
|
||||
$this->getOpt(CURLINFO_HEADER_OUT) !== true
|
||||
!$this->getOpt(CURLINFO_HEADER_OUT)
|
||||
)) {
|
||||
echo
|
||||
'Warning: Request headers (Curl::requestHeaders) are expected to be empty ' .
|
||||
@@ -1327,11 +1327,11 @@ class Curl extends BaseCurl
|
||||
}
|
||||
|
||||
if (!isset($this->responseHeaders['Content-Type'])) {
|
||||
echo 'Response did not set a content type' . "\n";
|
||||
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";
|
||||
echo 'Response appears to be JSON.' . "\n";
|
||||
} elseif (preg_match($this->xmlPattern, $this->responseHeaders['Content-Type'])) {
|
||||
echo 'Response appears to be XML' . "\n";
|
||||
echo 'Response appears to be XML.' . "\n";
|
||||
}
|
||||
|
||||
if ($this->curlError) {
|
||||
|
||||
@@ -4301,6 +4301,45 @@ class CurlTest extends \PHPUnit\Framework\TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function testDiagnoseRequestHeadersEmptyWarning()
|
||||
{
|
||||
$expect = 'Warning: Request headers (Curl::requestHeaders) are expected to be empty';
|
||||
|
||||
$test_1 = new Test();
|
||||
$test_1->curl->verbose();
|
||||
$test_1->server('json_response', 'GET');
|
||||
$test_1_output = $test_1->curl->diagnose(true);
|
||||
$this->assertStringContainsString($expect, $test_1_output);
|
||||
|
||||
$test_2 = new Test();
|
||||
$test_2->curl->setOpt(CURLOPT_VERBOSE, true);
|
||||
$test_2->curl->setOpt(CURLINFO_HEADER_OUT, false);
|
||||
$test_2->server('json_response', 'GET');
|
||||
$test_2_output = $test_2->curl->diagnose(true);
|
||||
$this->assertStringContainsString($expect, $test_2_output);
|
||||
|
||||
$test_3 = new Test();
|
||||
$test_3->curl->setOpt(CURLOPT_VERBOSE, true);
|
||||
$test_3->curl->setOpt(CURLINFO_HEADER_OUT, 0);
|
||||
$test_3->server('json_response', 'GET');
|
||||
$test_3_output = $test_3->curl->diagnose(true);
|
||||
$this->assertStringContainsString($expect, $test_3_output);
|
||||
|
||||
$test_4 = new Test();
|
||||
$test_4->curl->setOpt(CURLOPT_VERBOSE, 1);
|
||||
$test_4->curl->setOpt(CURLINFO_HEADER_OUT, false);
|
||||
$test_4->server('json_response', 'GET');
|
||||
$test_4_output = $test_4->curl->diagnose(true);
|
||||
$this->assertStringContainsString($expect, $test_4_output);
|
||||
|
||||
$test_5 = new Test();
|
||||
$test_5->curl->setOpt(CURLOPT_VERBOSE, 1);
|
||||
$test_5->curl->setOpt(CURLINFO_HEADER_OUT, 0);
|
||||
$test_5->server('json_response', 'GET');
|
||||
$test_5_output = $test_5->curl->diagnose(true);
|
||||
$this->assertStringContainsString($expect, $test_5_output);
|
||||
}
|
||||
|
||||
public function testStopRequest() {
|
||||
$response_length_bytes = 1e6; // 1e6 = 1 megabyte
|
||||
|
||||
|
||||
Reference in New Issue
Block a user