Annotation of embedaddon/php/ext/curl/tests/bug27023.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Bug #27023 (CURLOPT_POSTFIELDS does not parse content types for files)
! 3: --SKIPIF--
! 4: <?php
! 5: if (!extension_loaded("curl")) {
! 6: exit("skip curl extension not loaded");
! 7: }
! 8: if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
! 9: exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
! 10: }
! 11: ?>
! 12: --FILE--
! 13: <?php
! 14:
! 15: $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
! 16: $ch = curl_init();
! 17: curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=file");
! 18: curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
! 19:
! 20: $params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt');
! 21: curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
! 22: var_dump(curl_exec($ch));
! 23:
! 24: $params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt;type=text/plain');
! 25: curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
! 26: var_dump(curl_exec($ch));
! 27:
! 28: $params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt;filename=foo.txt');
! 29: curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
! 30: var_dump(curl_exec($ch));
! 31:
! 32: $params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt;type=text/plain;filename=foo.txt');
! 33: curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
! 34: var_dump(curl_exec($ch));
! 35:
! 36: $params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt;filename=foo.txt;type=text/plain');
! 37: curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
! 38: var_dump(curl_exec($ch));
! 39:
! 40:
! 41: curl_close($ch);
! 42: ?>
! 43: --EXPECTF--
! 44: string(%d) "curl_testdata1.txt|application/octet-stream"
! 45: string(%d) "curl_testdata1.txt|text/plain"
! 46: string(%d) "foo.txt|application/octet-stream"
! 47: string(%d) "foo.txt|text/plain"
! 48: string(%d) "foo.txt|text/plain"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>