From af3c9945f927e8e2ebdc8e7707b70ec3ba7addfc Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Mon, 20 Feb 2006 15:59:38 +0000 Subject: [PATCH] - add default stream context support --- http.c | 7 +++++-- http_api.c | 2 +- http_functions.c | 2 +- http_querystring_object.c | 1 + http_request_object.c | 2 +- php_http_send_api.h | 4 ++-- php_http_std_defs.h | 6 ++++++ 7 files changed, 17 insertions(+), 7 deletions(-) diff --git a/http.c b/http.c index 9b15c6c..75ca088 100644 --- a/http.c +++ b/http.c @@ -124,7 +124,7 @@ zend_function_entry http_functions[] = { /* {{{ http_module_dep */ #if ZEND_EXTENSION_API_NO >= 220050617 -static zend_module_dep http_module_dep[] = { +static zend_module_dep http_module_deps[] = { # ifdef HAVE_SPL ZEND_MOD_REQUIRED("spl") # endif @@ -134,6 +134,9 @@ static zend_module_dep http_module_dep[] = { # ifdef HAVE_PHP_SESSION ZEND_MOD_REQUIRED("session") # endif +#ifdef HAVE_ICONV + ZEND_MOD_REQUIRED("iconv") +#endif {NULL, NULL, NULL, 0} }; #endif @@ -143,7 +146,7 @@ static zend_module_dep http_module_dep[] = { zend_module_entry http_module_entry = { #if ZEND_EXTENSION_API_NO >= 220050617 STANDARD_MODULE_HEADER_EX, NULL, - http_module_dep, + http_module_deps, #else STANDARD_MODULE_HEADER, #endif diff --git a/http_api.c b/http_api.c index 811acba..285c030 100644 --- a/http_api.c +++ b/http_api.c @@ -116,7 +116,7 @@ void _http_log_ex(char *file, const char *ident, const char *message TSRMLS_DC) #define HTTP_LOG_WRITE(file, type, msg) \ if (file && *file) { \ - php_stream *log = php_stream_open_wrapper(file, "ab", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL); \ + php_stream *log = php_stream_open_wrapper(file, "ab", REPORT_ERRORS|ENFORCE_SAFE_MODE, HTTP_DEFAULT_STREAM_CONTEXT); \ \ if (log) { \ php_stream_printf(log TSRMLS_CC, "%s\t[%s]\t%s\t<%s>%s", datetime, type, msg, SG(request_info).request_uri, PHP_EOL); \ diff --git a/http_functions.c b/http_functions.c index 1c63ba0..b1e2256 100644 --- a/http_functions.c +++ b/http_functions.c @@ -1502,7 +1502,7 @@ PHP_FUNCTION(http_put_file) RETURN_FALSE; } - if (!(stream = php_stream_open_wrapper(file, "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL))) { + if (!(stream = php_stream_open_wrapper(file, "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, HTTP_DEFAULT_STREAM_CONTEXT))) { RETURN_FALSE; } if (php_stream_stat(stream, &ssb)) { diff --git a/http_querystring_object.c b/http_querystring_object.c index dab3dae..299a561 100644 --- a/http_querystring_object.c +++ b/http_querystring_object.c @@ -549,6 +549,7 @@ HTTP_QUERYSTRING_GETTER(getObject, IS_OBJECT); /* {{{ proto bool HttpQueryString::iconv(string ie, string oe) * * Converts the query string from the source encoding ie to the target encoding oe. + * WARNING: Don't use any character set that can contain NUL bytes like UTF-16. * * Returns TRUE on success or FALSE on failure. */ diff --git a/http_request_object.c b/http_request_object.c index 46b805a..8c4bc0e 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -450,7 +450,7 @@ STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_ case HTTP_PUT: { php_stream_statbuf ssb; - php_stream *stream = php_stream_open_wrapper(Z_STRVAL_P(GET_PROP(putFile)), "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL); + php_stream *stream = php_stream_open_wrapper(Z_STRVAL_P(GET_PROP(putFile)), "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, HTTP_DEFAULT_STREAM_CONTEXT); if (stream && !php_stream_stat(stream, &ssb)) { obj->request->body = http_request_body_init_ex(obj->request->body, HTTP_REQUEST_BODY_UPLOADFILE, stream, ssb.sb.st_size, 1); diff --git a/php_http_send_api.h b/php_http_send_api.h index aef4490..579ea35 100644 --- a/php_http_send_api.h +++ b/php_http_send_api.h @@ -61,8 +61,8 @@ PHP_HTTP_API STATUS _http_send_content_disposition(const char *filename, size_t #define http_send_ex(d, s, m, nc) _http_send_ex((d), (s), (m), (nc) TSRMLS_CC) PHP_HTTP_API STATUS _http_send_ex(const void *data, size_t data_size, http_send_mode mode, zend_bool no_cache TSRMLS_DC); -#define http_send_file(f) http_send_stream_ex(php_stream_open_wrapper(f, "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL), 1, 0) -#define http_send_file_ex(f, nc) http_send_stream_ex(php_stream_open_wrapper(f, "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL), 1, (nc)) +#define http_send_file(f) http_send_stream_ex(php_stream_open_wrapper(f, "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, HTTP_DEFAULT_STREAM_CONTEXT), 1, 0) +#define http_send_file_ex(f, nc) http_send_stream_ex(php_stream_open_wrapper(f, "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, HTTP_DEFAULT_STREAM_CONTEXT), 1, (nc)) #define http_send_stream(s) http_send_stream_ex((s), 0, 0) #define http_send_stream_ex(s, c, nc) _http_send_stream_ex((s), (c), (nc) TSRMLS_CC) PHP_HTTP_API STATUS _http_send_stream_ex(php_stream *s, zend_bool close_stream, zend_bool no_cache TSRMLS_DC); diff --git a/php_http_std_defs.h b/php_http_std_defs.h index 1b3d3bc..2e575a3 100644 --- a/php_http_std_defs.h +++ b/php_http_std_defs.h @@ -133,6 +133,12 @@ typedef int STATUS; "ACL, " \ /* END */ +#ifdef ZEND_ENGINE_2 +# include "ext/standard/file.h" +# define HTTP_DEFAULT_STREAM_CONTEXT FG(default_context) +#else +# define HTTP_DEFAULT_STREAM_CONTEXT NULL +#endif #define HTTP_PHP_INI_ENTRY(entry, default, scope, updater, global) \ STD_PHP_INI_ENTRY(entry, default, scope, updater, global, zend_http_globals, http_globals) -- 2.30.2