Skip to content

Commit a07759a

Browse files
committed
add --PUT-- section support based on POST_RAW
1 parent 1ef5fa8 commit a07759a

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

run-tests.php

+42-2
Original file line numberDiff line numberDiff line change
@@ -1342,8 +1342,8 @@ function run_test($php, $file, $env)
13421342

13431343
$tested = trim($section_text['TEST']);
13441344

1345-
/* For GET/POST tests, check if cgi sapi is available and if it is, use it. */
1346-
if (!empty($section_text['GET']) || !empty($section_text['POST']) || !empty($section_text['POST_RAW']) || !empty($section_text['COOKIE']) || !empty($section_text['EXPECTHEADERS'])) {
1345+
/* For GET/POST/PUT tests, check if cgi sapi is available and if it is, use it. */
1346+
if (!empty($section_text['GET']) || !empty($section_text['POST']) || !empty($section_text['POST_RAW']) || !empty($section_text['PUT']) || !empty($section_text['COOKIE']) || !empty($section_text['EXPECTHEADERS'])) {
13471347
if (isset($php_cgi)) {
13481348
$old_php = $php;
13491349
$php = $php_cgi . ' -C ';
@@ -1718,6 +1718,46 @@ function run_test($php, $file, $env)
17181718
save_text($tmp_post, $request);
17191719
$cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1 < \"$tmp_post\"";
17201720

1721+
} elseif (array_key_exists('PUT', $section_text) && !empty($section_text['PUT'])) {
1722+
1723+
$post = trim($section_text['PUT']);
1724+
$raw_lines = explode("\n", $post);
1725+
1726+
$request = '';
1727+
$started = false;
1728+
1729+
foreach ($raw_lines as $line) {
1730+
1731+
if (empty($env['CONTENT_TYPE']) && preg_match('/^Content-Type:(.*)/i', $line, $res)) {
1732+
$env['CONTENT_TYPE'] = trim(str_replace("\r", '', $res[1]));
1733+
continue;
1734+
}
1735+
1736+
if ($started) {
1737+
$request .= "\n";
1738+
}
1739+
1740+
$started = true;
1741+
$request .= $line;
1742+
}
1743+
1744+
$env['CONTENT_LENGTH'] = strlen($request);
1745+
$env['REQUEST_METHOD'] = 'PUT';
1746+
1747+
if (empty($request)) {
1748+
if ($JUNIT) {
1749+
$JUNIT['test_total']++;
1750+
$JUNIT['test_error']++;
1751+
$JUNIT['result_xml'] .= '<testcase classname="'.$shortname.'" name="'.htmlspecialchars($tested, ENT_QUOTES).'" time="'.$test_execution_time.'">'."\n";
1752+
$JUNIT['result_xml'] .= '<error type="BORKED" message="empty $request" />'."\n";
1753+
$JUNIT['result_xml'] .= '</testcase>'."\n";
1754+
}
1755+
return 'BORKED';
1756+
}
1757+
1758+
save_text($tmp_post, $request);
1759+
$cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1 < \"$tmp_post\"";
1760+
17211761
} else if (array_key_exists('POST', $section_text) && !empty($section_text['POST'])) {
17221762

17231763
$post = trim($section_text['POST']);

0 commit comments

Comments
 (0)