diff options
Diffstat (limited to 'ext/curl')
30 files changed, 512 insertions, 88 deletions
diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 23bd2edce..02f7fdf76 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: interface.c 313826 2011-07-28 10:31:34Z pajoye $ */ +/* $Id: interface.c 321634 2012-01-01 13:15:04Z felipe $ */ #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS @@ -150,6 +150,7 @@ static struct gcry_thread_cbs php_curl_gnutls_tsl = { static void _php_curl_close_ex(php_curl *ch TSRMLS_DC); static void _php_curl_close(zend_rsrc_list_entry *rsrc TSRMLS_DC); + #define SAVE_CURL_ERROR(__handle, __err) (__handle)->err.no = (int) __err; #define CAAL(s, v) add_assoc_long_ex(return_value, s, sizeof(s), (long) v); @@ -197,13 +198,79 @@ static int php_curl_option_url(php_curl *ch, const char *url, const int len) /* #else copystr = estrndup(url, len); error = curl_easy_setopt(ch->cp, CURLOPT_URL, copystr); - zend_llist_add_element(&ch->to_free.str, ©str); + zend_llist_add_element(&ch->to_free->str, ©str); #endif return (error == CURLE_OK ? 1 : 0); } /* }}} */ +int _php_curl_verify_handlers(php_curl *ch, int reporterror TSRMLS_DC) /* {{{ */ +{ + php_stream *stream; + if (!ch || !ch->handlers) { + return 0; + } + + if (ch->handlers->std_err) { + stream = (php_stream *) zend_fetch_resource(&ch->handlers->std_err TSRMLS_CC, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream()); + if (stream == NULL) { + if (reporterror) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLOPT_STDERR resource has gone away, resetting to stderr"); + } + zval_ptr_dtor(&ch->handlers->std_err); + ch->handlers->std_err = NULL; + + curl_easy_setopt(ch->cp, CURLOPT_STDERR, stderr); + } + } + if (ch->handlers->read && ch->handlers->read->stream) { + stream = (php_stream *) zend_fetch_resource(&ch->handlers->read->stream TSRMLS_CC, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream()); + if (stream == NULL) { + if (reporterror) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLOPT_INFILE resource has gone away, resetting to default"); + } + zval_ptr_dtor(&ch->handlers->read->stream); + ch->handlers->read->fd = 0; + ch->handlers->read->fp = 0; + ch->handlers->read->stream = NULL; + + curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch); + } + } + if (ch->handlers->write_header && ch->handlers->write_header->stream) { + stream = (php_stream *) zend_fetch_resource(&ch->handlers->write_header->stream TSRMLS_CC, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream()); + if (stream == NULL) { + if (reporterror) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLOPT_WRITEHEADER resource has gone away, resetting to default"); + } + zval_ptr_dtor(&ch->handlers->write_header->stream); + ch->handlers->write_header->fp = 0; + ch->handlers->write_header->stream = NULL; + + ch->handlers->write_header->method = PHP_CURL_IGNORE; + curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch); + } + } + if (ch->handlers->write && ch->handlers->write->stream) { + stream = (php_stream *) zend_fetch_resource(&ch->handlers->write->stream TSRMLS_CC, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream()); + if (stream == NULL) { + if (reporterror) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLOPT_FILE resource has gone away, resetting to default"); + } + zval_ptr_dtor(&ch->handlers->write->stream); + ch->handlers->write->fp = 0; + ch->handlers->write->stream = NULL; + + ch->handlers->write->method = PHP_CURL_STDOUT; + ch->handlers->write->type = PHP_CURL_ASCII; + curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch); + } + } + return 1; +} +/* }}} */ + /* {{{ arginfo */ ZEND_BEGIN_ARG_INFO_EX(arginfo_curl_version, 0, 0, 0) ZEND_ARG_INFO(0, version) @@ -337,7 +404,6 @@ PHP_INI_BEGIN() PHP_INI_END() /* }}} */ -/* }}} */ /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(curl) @@ -1346,6 +1412,7 @@ PHP_FUNCTION(curl_version) static void alloc_curl_handle(php_curl **ch) { *ch = emalloc(sizeof(php_curl)); + (*ch)->to_free = ecalloc(1, sizeof(struct _php_curl_free)); (*ch)->handlers = ecalloc(1, sizeof(php_curl_handlers)); (*ch)->handlers->write = ecalloc(1, sizeof(php_curl_write)); (*ch)->handlers->write_header = ecalloc(1, sizeof(php_curl_write)); @@ -1356,10 +1423,13 @@ static void alloc_curl_handle(php_curl **ch) (*ch)->header.str_len = 0; memset(&(*ch)->err, 0, sizeof((*ch)->err)); + (*ch)->handlers->write->stream = NULL; + (*ch)->handlers->write_header->stream = NULL; + (*ch)->handlers->read->stream = NULL; - zend_llist_init(&(*ch)->to_free.str, sizeof(char *), (llist_dtor_func_t) curl_free_string, 0); - zend_llist_init(&(*ch)->to_free.slist, sizeof(struct curl_slist), (llist_dtor_func_t) curl_free_slist, 0); - zend_llist_init(&(*ch)->to_free.post, sizeof(struct HttpPost), (llist_dtor_func_t) curl_free_post, 0); + zend_llist_init(&(*ch)->to_free->str, sizeof(char *), (llist_dtor_func_t) curl_free_string, 0); + zend_llist_init(&(*ch)->to_free->slist, sizeof(struct curl_slist), (llist_dtor_func_t) curl_free_slist, 0); + zend_llist_init(&(*ch)->to_free->post, sizeof(struct HttpPost), (llist_dtor_func_t) curl_free_post, 0); } /* }}} */ @@ -1394,6 +1464,7 @@ static void split_certinfo(char *string, zval *hash) efree(org); } } +/* }}} */ /* {{{ create_certinfo */ @@ -1537,6 +1608,7 @@ PHP_FUNCTION(curl_copy_handle) dupch->cp = cp; dupch->uses = 0; + ch->uses++; if (ch->handlers->write->stream) { Z_ADDREF_P(dupch->handlers->write->stream); dupch->handlers->write->stream = ch->handlers->write->stream; @@ -1577,18 +1649,21 @@ PHP_FUNCTION(curl_copy_handle) zval_add_ref(&ch->handlers->write_header->func_name); dupch->handlers->write_header->func_name = ch->handlers->write_header->func_name; } + + if (ch->handlers->progress->func_name) { + zval_add_ref(&ch->handlers->progress->func_name); + dupch->handlers->progress->func_name = ch->handlers->progress->func_name; + } + dupch->handlers->progress->method = ch->handlers->progress->method; curl_easy_setopt(dupch->cp, CURLOPT_ERRORBUFFER, dupch->err.str); curl_easy_setopt(dupch->cp, CURLOPT_FILE, (void *) dupch); curl_easy_setopt(dupch->cp, CURLOPT_INFILE, (void *) dupch); curl_easy_setopt(dupch->cp, CURLOPT_WRITEHEADER, (void *) dupch); + curl_easy_setopt(dupch->cp, CURLOPT_PROGRESSDATA, (void *) dupch); - zend_llist_copy(&dupch->to_free.str, &ch->to_free.str); - /* Don't try to free copied strings, they're free'd when the original handle is destroyed */ - dupch->to_free.str.dtor = NULL; - - zend_llist_copy(&dupch->to_free.slist, &ch->to_free.slist); - zend_llist_copy(&dupch->to_free.post, &ch->to_free.post); + efree(dupch->to_free); + dupch->to_free = ch->to_free; /* Keep track of cloned copies to avoid invoking curl destructors for every clone */ Z_ADDREF_P(ch->clone); @@ -1782,7 +1857,7 @@ string_copy: #endif copystr = estrndup(Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue)); error = curl_easy_setopt(ch->cp, option, copystr); - zend_llist_add_element(&ch->to_free.str, ©str); + zend_llist_add_element(&ch->to_free->str, ©str); } else { #if LIBCURL_VERSION_NUM >= 0x071100 /* Strings passed to libcurl as ’char *’ arguments, are copied by the library... NOTE: before 7.17.0 strings were not copied. */ @@ -1822,6 +1897,9 @@ string_copy: switch (option) { case CURLOPT_FILE: if (((php_stream *) what)->mode[0] != 'r' || ((php_stream *) what)->mode[1] == '+') { + if (ch->handlers->write->stream) { + Z_DELREF_P(ch->handlers->write->stream); + } Z_ADDREF_PP(zvalue); ch->handlers->write->fp = fp; ch->handlers->write->method = PHP_CURL_FILE; @@ -1834,6 +1912,9 @@ string_copy: break; case CURLOPT_WRITEHEADER: if (((php_stream *) what)->mode[0] != 'r' || ((php_stream *) what)->mode[1] == '+') { + if (ch->handlers->write_header->stream) { + Z_DELREF_P(ch->handlers->write_header->stream); + } Z_ADDREF_PP(zvalue); ch->handlers->write_header->fp = fp; ch->handlers->write_header->method = PHP_CURL_FILE; @@ -1845,6 +1926,9 @@ string_copy: } break; case CURLOPT_INFILE: + if (ch->handlers->read->stream) { + Z_DELREF_P(ch->handlers->read->stream); + } Z_ADDREF_PP(zvalue); ch->handlers->read->fp = fp; ch->handlers->read->fd = Z_LVAL_PP(zvalue); @@ -2014,7 +2098,7 @@ string_copy: return 1; } - zend_llist_add_element(&ch->to_free.post, &first); + zend_llist_add_element(&ch->to_free->post, &first); error = curl_easy_setopt(ch->cp, CURLOPT_HTTPPOST, first); } else { @@ -2028,7 +2112,7 @@ string_copy: convert_to_string_ex(zvalue); post = estrndup(Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue)); - zend_llist_add_element(&ch->to_free.str, &post); + zend_llist_add_element(&ch->to_free->str, &post); error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDS, post); error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, Z_STRLEN_PP(zvalue)); @@ -2064,7 +2148,7 @@ string_copy: return 1; } } - zend_llist_add_element(&ch->to_free.slist, &slist); + zend_llist_add_element(&ch->to_free->slist, &slist); error = curl_easy_setopt(ch->cp, option, slist); @@ -2094,7 +2178,7 @@ string_copy: copystr = estrndup(Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue)); error = curl_easy_setopt(ch->cp, option, copystr); - zend_llist_add_element(&ch->to_free.str, ©str); + zend_llist_add_element(&ch->to_free->str, ©str); #endif break; } @@ -2211,6 +2295,8 @@ PHP_FUNCTION(curl_exec) ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); + _php_curl_verify_handlers(ch, 1 TSRMLS_CC); + _php_curl_cleanup_handle(ch); error = curl_easy_perform(ch->cp); @@ -2223,6 +2309,14 @@ PHP_FUNCTION(curl_exec) RETURN_FALSE; } + if (ch->handlers->std_err) { + php_stream *stream; + stream = (php_stream*)zend_fetch_resource(&ch->handlers->std_err TSRMLS_CC, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream()); + if (stream) { + php_stream_flush(stream); + } + } + if (ch->handlers->write->method == PHP_CURL_RETURN && ch->handlers->write->buf.len > 0) { smart_str_0(&ch->handlers->write->buf); RETURN_STRINGL(ch->handlers->write->buf.c, ch->handlers->write->buf.len, 1); @@ -2500,25 +2594,18 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC) fprintf(stderr, "DTOR CALLED, ch = %x\n", ch); #endif - /* Prevent crash inside cURL if passed file has already been closed */ - if (ch->handlers->std_err && Z_REFCOUNT_P(ch->handlers->std_err) <= 0) { - curl_easy_setopt(ch->cp, CURLOPT_STDERR, stderr); - } - + _php_curl_verify_handlers(ch, 0 TSRMLS_CC); curl_easy_cleanup(ch->cp); - zend_llist_clean(&ch->to_free.str); /* cURL destructors should be invoked only by last curl handle */ if (Z_REFCOUNT_P(ch->clone) <= 1) { - zend_llist_clean(&ch->to_free.slist); - zend_llist_clean(&ch->to_free.post); + zend_llist_clean(&ch->to_free->str); + zend_llist_clean(&ch->to_free->slist); + zend_llist_clean(&ch->to_free->post); + efree(ch->to_free); FREE_ZVAL(ch->clone); } else { Z_DELREF_P(ch->clone); - ch->to_free.slist.dtor = NULL; - ch->to_free.post.dtor = NULL; - zend_llist_clean(&ch->to_free.slist); - zend_llist_clean(&ch->to_free.post); } if (ch->handlers->write->buf.len > 0) { diff --git a/ext/curl/multi.c b/ext/curl/multi.c index 98a08159e..8679797aa 100644 --- a/ext/curl/multi.c +++ b/ext/curl/multi.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: multi.c 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: multi.c 321634 2012-01-01 13:15:04Z felipe $ */ #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS @@ -211,6 +211,19 @@ PHP_FUNCTION(curl_multi_exec) ZEND_FETCH_RESOURCE(mh, php_curlm *, &z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle); + { + zend_llist_position pos; + php_curl *ch; + zval *pz_ch; + + for(pz_ch = (zval *)zend_llist_get_first_ex(&mh->easyh, &pos); pz_ch; + pz_ch = (zval *)zend_llist_get_next_ex(&mh->easyh, &pos)) { + + ZEND_FETCH_RESOURCE(ch, php_curl *, &pz_ch, -1, le_curl_name, le_curl); + _php_curl_verify_handlers(ch, 1 TSRMLS_CC); + } + } + convert_to_long_ex(&z_still_running); still_running = Z_LVAL_P(z_still_running); result = curl_multi_perform(mh->multi, &still_running); @@ -324,6 +337,17 @@ void _php_curl_multi_close(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */ { php_curlm *mh = (php_curlm *) rsrc->ptr; if (mh) { + zend_llist_position pos; + php_curl *ch; + zval *pz_ch; + + for(pz_ch = (zval *)zend_llist_get_first_ex(&mh->easyh, &pos); pz_ch; + pz_ch = (zval *)zend_llist_get_next_ex(&mh->easyh, &pos)) { + + ch = (php_curl *) zend_fetch_resource(&pz_ch TSRMLS_CC, -1, le_curl_name, NULL, 1, le_curl); + _php_curl_verify_handlers(ch, 0 TSRMLS_CC); + } + curl_multi_cleanup(mh->multi); zend_llist_clean(&mh->easyh); efree(mh); diff --git a/ext/curl/php_curl.h b/ext/curl/php_curl.h index 844cc0ab3..88cd4686a 100644 --- a/ext/curl/php_curl.h +++ b/ext/curl/php_curl.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_curl.h 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: php_curl.h 321634 2012-01-01 13:15:04Z felipe $ */ #ifndef _PHP_CURL_H #define _PHP_CURL_H @@ -131,7 +131,7 @@ struct _php_curl_free { typedef struct { struct _php_curl_error err; - struct _php_curl_free to_free; + struct _php_curl_free *to_free; struct _php_curl_send_headers header; void ***thread_ctx; CURL *cp; @@ -150,6 +150,7 @@ typedef struct { void _php_curl_cleanup_handle(php_curl *); void _php_curl_multi_cleanup_list(void *data); +int _php_curl_verify_handlers(php_curl *ch, int reporterror TSRMLS_DC); /* streams support */ diff --git a/ext/curl/streams.c b/ext/curl/streams.c index 264f33d26..525a351c3 100644 --- a/ext/curl/streams.c +++ b/ext/curl/streams.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streams.c 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: streams.c 321634 2012-01-01 13:15:04Z felipe $ */ /* This file implements cURL based wrappers. * NOTE: If you are implementing your own streams that are intended to diff --git a/ext/curl/tests/bug27023.phpt b/ext/curl/tests/bug27023.phpt new file mode 100644 index 000000000..b738c956e --- /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-- +<?php +if (!extension_loaded("curl")) { + exit("skip curl extension not loaded"); +} +if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { + exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); +} +?> +--FILE-- +<?php + +$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +$ch = curl_init(); +curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=file"); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + +$params = array('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;filename=foo.txt;type=text/plain'); +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/bug48203.phpt b/ext/curl/tests/bug48203.phpt index 84fcf83a0..d8f4d2269 100644 --- a/ext/curl/tests/bug48203.phpt +++ b/ext/curl/tests/bug48203.phpt @@ -18,16 +18,19 @@ $ch = curl_init(); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_STDERR, $fp); -curl_setopt($ch, CURLOPT_URL, ""); +curl_setopt($ch, CURLOPT_URL, getenv('PHP_CURL_HTTP_REMOTE_SERVER')); fclose($fp); // <-- premature close of $fp caused a crash! curl_exec($ch); +curl_close($ch); echo "Ok\n"; ?> --CLEAN-- <?php @unlink(dirname(__FILE__) . '/bug48203.tmp'); ?> ---EXPECT-- +--EXPECTF-- +Warning: curl_exec(): CURLOPT_STDERR resource has gone away, resetting to stderr in %sbug48203.php on line %d +%A Ok diff --git a/ext/curl/tests/bug48203_multi.phpt b/ext/curl/tests/bug48203_multi.phpt new file mode 100644 index 000000000..7d4ee4769 --- /dev/null +++ b/ext/curl/tests/bug48203_multi.phpt @@ -0,0 +1,90 @@ +--TEST-- +Variation of bug #48203 with curl_multi_exec (Crash when file pointers passed to curl are closed before calling curl_multi_exec) +--SKIPIF-- +<?php +if (!extension_loaded("curl")) { + exit("skip curl extension not loaded"); +} +if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { + exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); +} +?> +--FILE-- +<?php + +function checkForClosedFilePointer($curl_option, $description) { + $fp = fopen(dirname(__FILE__) . '/bug48203.tmp', 'w'); + + $ch1 = curl_init(); + $ch2 = curl_init(); + + $options = array( + CURLOPT_RETURNTRANSFER => 1, + $curl_option => $fp, + CURLOPT_URL => getenv("PHP_CURL_HTTP_REMOTE_SERVER") + ); + + // we also need to set CURLOPT_VERBOSE to test CURLOPT_STDERR properly + if (CURLOPT_STDERR == $curl_option) { + $options[CURLOPT_VERBOSE] = 1; + } + + if (CURLOPT_INFILE == $curl_option) { + $options[CURLOPT_UPLOAD] = 1; + } + + curl_setopt_array($ch1, $options); + curl_setopt_array($ch2, $options); + + fclose($fp); // <-- premature close of $fp caused a crash! + + $mh = curl_multi_init(); + + curl_multi_add_handle($mh, $ch1); + curl_multi_add_handle($mh, $ch2); + + $active = 0; + do { + curl_multi_exec($mh, $active); + } while ($active > 0); + + curl_multi_remove_handle($mh, $ch1); + curl_multi_remove_handle($mh, $ch2); + curl_multi_close($mh); + + echo "Ok for $description\n"; +} + +$options_to_check = array( + "CURLOPT_STDERR", "CURLOPT_WRITEHEADER", "CURLOPT_FILE", "CURLOPT_INFILE" +); + +foreach($options_to_check as $option) { + checkForClosedFilePointer(constant($option), $option); +} + +?> +--CLEAN-- +<?php @unlink(dirname(__FILE__) . '/bug48203.tmp'); ?> +--EXPECTF-- +Warning: curl_multi_exec(): CURLOPT_STDERR resource has gone away, resetting to stderr in %sbug48203_multi.php on line 36 + +Warning: curl_multi_exec(): CURLOPT_STDERR resource has gone away, resetting to stderr in %sbug48203_multi.php on line 36 +%A +Ok for CURLOPT_STDERR +%A +Warning: curl_multi_exec(): CURLOPT_WRITEHEADER resource has gone away, resetting to default in %sbug48203_multi.php on line 36 + +Warning: curl_multi_exec(): CURLOPT_WRITEHEADER resource has gone away, resetting to default in %sbug48203_multi.php on line 36 +Ok for CURLOPT_WRITEHEADER + +Warning: curl_multi_exec(): CURLOPT_FILE resource has gone away, resetting to default in %sbug48203_multi.php on line 36 + +Warning: curl_multi_exec(): CURLOPT_FILE resource has gone away, resetting to default in %sbug48203_multi.php on line 36 +%A +Ok for CURLOPT_FILE + +Warning: curl_multi_exec(): CURLOPT_INFILE resource has gone away, resetting to default in %sbug48203_multi.php on line 36 + +Warning: curl_multi_exec(): CURLOPT_INFILE resource has gone away, resetting to default in %sbug48203_multi.php on line 36 +Ok for CURLOPT_INFILE diff --git a/ext/curl/tests/bug54798.phpt b/ext/curl/tests/bug54798.phpt new file mode 100644 index 000000000..7ec84adda --- /dev/null +++ b/ext/curl/tests/bug54798.phpt @@ -0,0 +1,72 @@ +--TEST-- +Bug #54798 (Segfault when CURLOPT_STDERR file pointer is closed before calling curl_exec) +--SKIPIF-- +<?php +if (!extension_loaded("curl")) { + exit("skip curl extension not loaded"); +} +if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { + exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); +} +?> +--FILE-- +<?php + +function checkForClosedFilePointer($host, $curl_option, $description) { + $fp = fopen(dirname(__FILE__) . '/bug54798.tmp', 'w+'); + + $ch = curl_init(); + + // we also need CURLOPT_VERBOSE to be set to test CURLOPT_STDERR properly + if (CURLOPT_STDERR == $curl_option) { + curl_setopt($ch, CURLOPT_VERBOSE, 1); + } + + if (CURLOPT_INFILE == $curl_option) { + curl_setopt($ch, CURLOPT_UPLOAD, 1); + } + + curl_setopt($ch, $curl_option, $fp); + + curl_setopt($ch, CURLOPT_URL, $host); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + fclose($fp); // <-- premature close of $fp caused a crash! + + curl_exec($ch); + + curl_close($ch); + + echo "Ok for $description\n"; +} + +$options_to_check = array( + "CURLOPT_STDERR", + "CURLOPT_WRITEHEADER", + "CURLOPT_FILE", + "CURLOPT_INFILE" +); + +$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +foreach($options_to_check as $option) { + checkForClosedFilePointer($host, constant($option), $option); +} + +?> +--CLEAN-- +<?php @unlink(dirname(__FILE__) . '/bug54798.tmp'); ?> +--EXPECTF-- +Warning: curl_exec(): CURLOPT_STDERR resource has gone away, resetting to stderr in %sbug54798.php on line %d +* About to connect() %a +* Closing connection #%d +Ok for CURLOPT_STDERR + +Warning: curl_exec(): CURLOPT_WRITEHEADER resource has gone away, resetting to default in %sbug54798.php on line 24 +Ok for CURLOPT_WRITEHEADER + +Warning: curl_exec(): CURLOPT_FILE resource has gone away, resetting to default in %sbug54798.php on line 24 +%a +Ok for CURLOPT_FILE + +Warning: curl_exec(): CURLOPT_INFILE resource has gone away, resetting to default in %sbug54798.php on line %d +Ok for CURLOPT_INFILE diff --git a/ext/curl/tests/curl_CURLOPT_READDATA.phpt b/ext/curl/tests/curl_CURLOPT_READDATA.phpt index 00f3ea95a..ea63d445a 100644 --- a/ext/curl/tests/curl_CURLOPT_READDATA.phpt +++ b/ext/curl/tests/curl_CURLOPT_READDATA.phpt @@ -4,7 +4,7 @@ Test CURLOPT_READDATA without a callback function Mattijs Hoitink mattijshoitink@gmail.com #Testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> --FILE-- <?php diff --git a/ext/curl/tests/curl_basic_008.phpt b/ext/curl/tests/curl_basic_008.phpt index 32de4d0f5..29e334370 100755 --- a/ext/curl/tests/curl_basic_008.phpt +++ b/ext/curl/tests/curl_basic_008.phpt @@ -3,7 +3,13 @@ Test curl_error() & curl_errno() function with problematic host --CREDITS-- TestFest 2009 - AFUP - Perrick Penet <perrick@noparking.net> --SKIPIF-- -<?php if (!extension_loaded("curl")) print "skip"; ?> +<?php + if (!extension_loaded("curl")) print "skip"; + $addr = "www.".uniqid().".".uniqid(); + if (gethostbyname($addr) != $addr) { + print "skip catch all dns"; + } +?> --FILE-- <?php diff --git a/ext/curl/tests/curl_basic_010.phpt b/ext/curl/tests/curl_basic_010.phpt index 9a595b3c0..7da64d39b 100644 --- a/ext/curl/tests/curl_basic_010.phpt +++ b/ext/curl/tests/curl_basic_010.phpt @@ -3,7 +3,13 @@ Test curl_error() & curl_errno() function with problematic proxy --CREDITS-- TestFest 2009 - AFUP - Perrick Penet <perrick@noparking.net> --SKIPIF-- -<?php if (!extension_loaded("curl")) print "skip"; ?> +<?php + if (!extension_loaded("curl")) print "skip"; + $addr = "www.".uniqid().".".uniqid(); + if (gethostbyname($addr) != $addr) { + print "skip catch all dns"; + } +?> --FILE-- <?php diff --git a/ext/curl/tests/curl_basic_011.phpt b/ext/curl/tests/curl_basic_011.phpt index dfdc8f9e0..10c90b123 100644 --- a/ext/curl/tests/curl_basic_011.phpt +++ b/ext/curl/tests/curl_basic_011.phpt @@ -3,7 +3,7 @@ Test curl_opt() function with COOKIE --CREDITS-- TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com> --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv(b'PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php if (!extension_loaded("curl") || false === getenv(b'PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> --FILE-- <?php /* Prototype : bool curl_setopt(resource ch, int option, mixed value) @@ -35,4 +35,4 @@ TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com> *** Testing curl with cookie *** string(3) "bar" ===DONE=== -
\ No newline at end of file + diff --git a/ext/curl/tests/curl_copy_handle_basic_001.phpt b/ext/curl/tests/curl_copy_handle_basic_001.phpt index db4bf0233..f1b4db3ce 100644 --- a/ext/curl/tests/curl_copy_handle_basic_001.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_001.phpt @@ -4,7 +4,7 @@ Test curl_copy_handle() with simple get Rick Buitenman <rick@meritos.nl> #testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> --FILE-- <?php @@ -39,4 +39,4 @@ string(106) "array(2) { array(0) { } " -===DONE===
\ No newline at end of file +===DONE=== diff --git a/ext/curl/tests/curl_copy_handle_basic_002.phpt b/ext/curl/tests/curl_copy_handle_basic_002.phpt index 8a3582384..9ab33635f 100644 --- a/ext/curl/tests/curl_copy_handle_basic_002.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_002.phpt @@ -4,7 +4,7 @@ Test curl_copy_handle() with simple POST Rick Buitenman <rick@meritos.nl> #testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> --FILE-- <?php $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); @@ -29,8 +29,6 @@ Rick Buitenman <rick@meritos.nl> var_dump( $curl_content ); ?> ===DONE=== ---XFAIL-- -This test fails, the copy seems to be missing the CURLOPT_POSTFIELDS after the original is closed --EXPECTF-- *** Testing curl copy handle with simple POST *** string(163) "array(1) { diff --git a/ext/curl/tests/curl_copy_handle_basic_004.phpt b/ext/curl/tests/curl_copy_handle_basic_004.phpt index 2b75eb6a4..9b794e91b 100644 --- a/ext/curl/tests/curl_copy_handle_basic_004.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_004.phpt @@ -4,7 +4,7 @@ Test curl_copy_handle() after exec() Rick Buitenman <rick@meritos.nl> #testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> --FILE-- <?php @@ -41,4 +41,4 @@ string(106) "array(2) { array(0) { } " -===DONE===
\ No newline at end of file +===DONE=== diff --git a/ext/curl/tests/curl_copy_handle_basic_005.phpt b/ext/curl/tests/curl_copy_handle_basic_005.phpt index dcc7e47af..aa9e2fa99 100644 --- a/ext/curl/tests/curl_copy_handle_basic_005.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_005.phpt @@ -4,7 +4,7 @@ Test curl_copy_handle() after exec() with POST Rick Buitenman <rick@meritos.nl> #testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> --FILE-- <?php @@ -32,8 +32,6 @@ Rick Buitenman <rick@meritos.nl> var_dump( $curl_content_copy ); ?> ===DONE=== ---XFAIL-- -This test fails, the output of the copy seems to be corrupted if the original is closed after exec() --EXPECTF-- *** Test curl_copy_handle() after exec() with POST *** string(163) "array(1) { diff --git a/ext/curl/tests/curl_copy_handle_basic_006.phpt b/ext/curl/tests/curl_copy_handle_basic_006.phpt index d2374c721..defc0f232 100644 --- a/ext/curl/tests/curl_copy_handle_basic_006.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_006.phpt @@ -4,7 +4,7 @@ Test curl_copy_handle() with User Agent Rick Buitenman <rick@meritos.nl> #testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> --FILE-- <?php diff --git a/ext/curl/tests/curl_copy_handle_basic_007.phpt b/ext/curl/tests/curl_copy_handle_basic_007.phpt index a51d9f6df..aa7306c1c 100644 --- a/ext/curl/tests/curl_copy_handle_basic_007.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_007.phpt @@ -1,7 +1,7 @@ --TEST-- Test curl_copy_handle() with simple POST --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> --FILE-- <?php $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); diff --git a/ext/curl/tests/curl_copy_handle_basic_008.phpt b/ext/curl/tests/curl_copy_handle_basic_008.phpt new file mode 100644 index 000000000..692c2df19 --- /dev/null +++ b/ext/curl/tests/curl_copy_handle_basic_008.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test curl_copy_handle() with CURLOPT_PROGRESSFUNCTION +--SKIPIF-- +<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +--FILE-- +<?php + $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + + $url = "{$host}/get.php"; + $ch = curl_init($url); + + curl_setopt($ch, CURLOPT_NOPROGRESS, 0); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function() { }); + $ch2 = curl_copy_handle($ch); + echo curl_exec($ch), PHP_EOL; + unset($ch); + echo curl_exec($ch2); + +?> +--EXPECTF-- +Hello World! +Hello World! +Hello World! +Hello World! diff --git a/ext/curl/tests/curl_error_basic.phpt b/ext/curl/tests/curl_error_basic.phpt index c9aa9ef8a..bd01847f0 100644 --- a/ext/curl/tests/curl_error_basic.phpt +++ b/ext/curl/tests/curl_error_basic.phpt @@ -4,7 +4,15 @@ curl_error() function - basic test for curl_error using a fake url Mattijs Hoitink mattijshoitink@gmail.com #Testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl")) print "skip"; ?> +<?php + +if (!extension_loaded("curl")) die("skip\n"); + +$url = "fakeURL"; +$ip = gethostbyname($url); +if ($ip != $url) die("skip 'fakeURL' resolves to $ip\n"); + +?> --FILE-- <?php /* @@ -21,13 +29,13 @@ echo "== Testing curl_error with a fake URL ==\n"; // cURL handler $ch = curl_init($url); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); -ob_start(); // start output buffering curl_exec($ch); -echo "Error: " . curl_error($ch); +var_dump(curl_error($ch)); curl_close($ch); ?> ---EXPECT-- +--EXPECTF-- == Testing curl_error with a fake URL == -Error: Couldn't resolve host 'fakeURL' +string(%d) "%sfakeURL%s" diff --git a/ext/curl/tests/curl_file_deleted_before_curl_close.phpt b/ext/curl/tests/curl_file_deleted_before_curl_close.phpt new file mode 100644 index 000000000..592f110fb --- /dev/null +++ b/ext/curl/tests/curl_file_deleted_before_curl_close.phpt @@ -0,0 +1,38 @@ +--TEST-- +Memory corruption error if fp of just created file is closed before curl_close. +--CREDITS-- +Alexey Shein <confik@gmail.com> +--SKIPIF-- +<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +--FILE-- +<?php + +$ch = curl_init(getenv('PHP_CURL_HTTP_REMOTE_SERVER')); + +$temp_file = dirname(__FILE__) . '/curl_file_deleted_before_curl_close.tmp'; +if (file_exists($temp_file)) { + unlink($temp_file); // file should not exist before test +} + +$handle = fopen($temp_file, 'w'); + +curl_setopt($ch, CURLOPT_STDERR, $handle); +curl_setopt($ch, CURLOPT_VERBOSE, 1); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + +curl_exec($ch); + +fclose($handle); // causes glibc memory error + +//unlink($temp_file); // uncomment to test segfault (file not found on iowrite.c) + +curl_close($ch); +echo "Closed correctly\n"; +?> +--CLEAN-- +<?php +unlink(dirname(__FILE__) . '/curl_file_deleted_before_curl_close.tmp'); +?> +--EXPECTF-- +* Closing connection #%d +Closed correctly diff --git a/ext/curl/tests/curl_multi_getcontent_basic3.phpt b/ext/curl/tests/curl_multi_getcontent_basic3.phpt index bf17ab6b6..ac2a37172 100644 --- a/ext/curl/tests/curl_multi_getcontent_basic3.phpt +++ b/ext/curl/tests/curl_multi_getcontent_basic3.phpt @@ -5,7 +5,10 @@ Rein Velt (rein@velt.org) #TestFest Utrecht 20090509 --SKIPIF-- <?php -if (!extension_loaded('curl')) print 'skip'; +if (!extension_loaded('curl')) print 'skip need ext/curl'; +if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { + exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); +} ?> --FILE-- <?php @@ -16,7 +19,8 @@ if (!extension_loaded('curl')) print 'skip'; $ch2=curl_init(); //SET URL AND OTHER OPTIONS - curl_setopt($ch1, CURLOPT_URL, "http://php.net/robots.txt"); + $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + curl_setopt($ch1, CURLOPT_URL, "{$host}/get.php?test=getpost&get_param=Hello%20World"); curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata2.txt"); curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true); @@ -46,19 +50,13 @@ if (!extension_loaded('curl')) print 'skip'; echo $results2; ?> ---EXPECT-- -User-agent: * -Disallow: /backend/ -Disallow: /distributions/ -Disallow: /stats/ -Disallow: /source.php -Disallow: /search.php -Disallow: /mod.php -Disallow: /manual/add-note.php - -Disallow: /harming/humans -Disallow: /ignoring/human/orders -Disallow: /harm/to/self - +--EXPECTF-- +array(2) { + ["test"]=> + string(7) "getpost" + ["get_param"]=> + string(11) "Hello World" +} +array(0) { +} CURL2 - diff --git a/ext/curl/tests/curl_setopt_array_basic.phpt b/ext/curl/tests/curl_setopt_array_basic.phpt index 877079bca..427de7fc7 100644 --- a/ext/curl/tests/curl_setopt_array_basic.phpt +++ b/ext/curl/tests/curl_setopt_array_basic.phpt @@ -46,6 +46,7 @@ $returnContent = curl_exec($ch); curl_close($ch); var_dump($returnContent); +isset($tempname) and is_file($tempname) and @unlink($tempname); ?> --EXPECT-- diff --git a/ext/curl/tests/curl_setopt_basic002.phpt b/ext/curl/tests/curl_setopt_basic002.phpt index 051703fb0..d90ecb7bd 100644 --- a/ext/curl/tests/curl_setopt_basic002.phpt +++ b/ext/curl/tests/curl_setopt_basic002.phpt @@ -4,7 +4,7 @@ curl_setopt basic tests with CURLOPT_STDERR. Paul Sohier #phptestfest utrecht --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> --FILE-- <?php @@ -26,7 +26,7 @@ $curl_content = curl_exec($ch); fclose($handle); unset($handle); -var_dump( file_get_contents($temp_file) ); +var_dump(preg_replace('/[\r\n]/', ' ', file_get_contents($temp_file))); @unlink($temp_file); ob_start(); // start output buffering @@ -38,7 +38,7 @@ ob_end_clean(); fclose($handle); unset($handle); -var_dump( file_get_contents($temp_file) ); +var_dump(preg_replace('/[\r\n]/', ' ', file_get_contents($temp_file))); @unlink($temp_file); curl_close($ch); @@ -48,3 +48,5 @@ curl_close($ch); *** Testing curl_setopt with CURLOPT_STDERR string(%d) "%S" string(%d) "%S" +* Closing connection #%d + diff --git a/ext/curl/tests/curl_setopt_basic003.phpt b/ext/curl/tests/curl_setopt_basic003.phpt index 47ae0f773..784914076 100644 --- a/ext/curl/tests/curl_setopt_basic003.phpt +++ b/ext/curl/tests/curl_setopt_basic003.phpt @@ -4,7 +4,7 @@ curl_setopt() call with CURLOPT_HTTPHEADER Paul Sohier #phptestfest utrecht --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> --FILE-- <?php diff --git a/ext/curl/tests/curl_setopt_basic004.phpt b/ext/curl/tests/curl_setopt_basic004.phpt index 63f956162..97b4115e3 100644 --- a/ext/curl/tests/curl_setopt_basic004.phpt +++ b/ext/curl/tests/curl_setopt_basic004.phpt @@ -4,7 +4,7 @@ curl_setopt() call with CURLOPT_RETURNTRANSFER Paul Sohier #phptestfest utrecht --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> --FILE-- <?php diff --git a/ext/curl/tests/curl_version_error.phpt b/ext/curl/tests/curl_version_error.phpt index f9de8dd32..fb4793af1 100644 --- a/ext/curl/tests/curl_version_error.phpt +++ b/ext/curl/tests/curl_version_error.phpt @@ -2,9 +2,12 @@ Test curl_version() function : error conditions
--SKIPIF--
<?php
-if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
+if (!extension_loaded("curl")) {
die('skip - curl extension not available in this build');
}
+if (!getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
+ echo "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable";
+}
?>
--FILE--
<?php
diff --git a/ext/curl/tests/curl_version_variation1.phpt b/ext/curl/tests/curl_version_variation1.phpt index 4b8676099..cd912c480 100644 --- a/ext/curl/tests/curl_version_variation1.phpt +++ b/ext/curl/tests/curl_version_variation1.phpt @@ -2,8 +2,11 @@ Test curl_version() function : usage variations - test values for $ascii argument
--SKIPIF--
<?php
-if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
- die('skip - curl extension not available in this build');
+if (!extension_loaded("curl")) {
+ echo "skip - curl extension not available in this build";
+}
+if (!getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
+ echo "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable";
}
?>
--FILE--
diff --git a/ext/curl/tests/curl_writeheader_callback.phpt b/ext/curl/tests/curl_writeheader_callback.phpt index ae0075c84..fa27363a4 100644 --- a/ext/curl/tests/curl_writeheader_callback.phpt +++ b/ext/curl/tests/curl_writeheader_callback.phpt @@ -6,7 +6,14 @@ Dutch UG, TestFest 2009, Utrecht --DESCRIPTION-- Hit the host identified by PHP_CURL_HTTP_REMOTE_SERVER and determine that the headers are sent to the callback specified for CURLOPT_HEADERFUNCTION. Different test servers specified for PHP_CURL_HTTP_REMOTE_SERVER might return different sets of headers. Just test for HTTP/1.1 200 OK. --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php +if (!extension_loaded("curl")) { + echo "skip - curl extension not available in this build"; +} +if (!getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { + echo "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; +} +?> --FILE-- <?php diff --git a/ext/curl/tests/responder/get.php b/ext/curl/tests/responder/get.php index e77faa57d..9e13d6a74 100644 --- a/ext/curl/tests/responder/get.php +++ b/ext/curl/tests/responder/get.php @@ -1,5 +1,6 @@ <?php - switch($_GET['test']) { + $test = isset($_GET['test']) ? $_GET['test'] : null; + switch($test) { case 'post': var_dump($_POST); break; @@ -25,6 +26,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!"; |
