From: Pierrick Charron Date: Wed, 7 Dec 2011 16:32:50 +0000 (+0000) Subject: Add new test for CURLOPT_POSTFIELDS X-Git-Tag: php-5.3.9RC3~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4093e5e797c440365d6aa16030c168857a65c2ab;p=php Add new test for CURLOPT_POSTFIELDS --- diff --git a/ext/curl/tests/bug27023.phpt b/ext/curl/tests/bug27023.phpt new file mode 100644 index 0000000000..ca42c60927 --- /dev/null +++ b/ext/curl/tests/bug27023.phpt @@ -0,0 +1,48 @@ +--TEST-- +Bug #27023 (CURLOPT_POSTFIELDS does not parse content types for files) +--SKIPIF-- + +--FILE-- + '@' . __DIR__ . '/curl_testdata1.txt'); +curl_setopt($ch, CURLOPT_POSTFIELDS, $params); +var_dump(curl_exec($ch)); + +$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt;type=text/plain'); +curl_setopt($ch, CURLOPT_POSTFIELDS, $params); +var_dump(curl_exec($ch)); + +$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt;filename=foo.txt'); +curl_setopt($ch, CURLOPT_POSTFIELDS, $params); +var_dump(curl_exec($ch)); + +$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt;type=text/plain;filename=foo.txt'); +curl_setopt($ch, CURLOPT_POSTFIELDS, $params); +var_dump(curl_exec($ch)); + +$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt;type=text/plain;filename=foo.txt'); +curl_setopt($ch, CURLOPT_POSTFIELDS, $params); +var_dump(curl_exec($ch)); + + +curl_close($ch); +?> +--EXPECTF-- +string(%d) "curl_testdata1.txt|application/octet-stream" +string(%d) "curl_testdata1.txt|text/plain" +string(%d) "foo.txt|application/octet-stream" +string(%d) "foo.txt|text/plain" +string(%d) "foo.txt|text/plain" diff --git a/ext/curl/tests/responder/get.php b/ext/curl/tests/responder/get.php index e77faa57d9..daffdfca08 100644 --- a/ext/curl/tests/responder/get.php +++ b/ext/curl/tests/responder/get.php @@ -25,6 +25,11 @@ case 'contenttype': header('Content-Type: text/plain;charset=utf-8'); break; + case 'file': + if (isset($_FILES['file'])) { + echo $_FILES['file']['name'] . '|' . $_FILES['file']['type']; + } + break; default: echo "Hello World!\n"; echo "Hello World!";