- add default stream context support
authorMichael Wallner <mike@php.net>
Mon, 20 Feb 2006 15:59:38 +0000 (15:59 +0000)
committerMichael Wallner <mike@php.net>
Mon, 20 Feb 2006 15:59:38 +0000 (15:59 +0000)
http.c
http_api.c
http_functions.c
http_querystring_object.c
http_request_object.c
php_http_send_api.h
php_http_std_defs.h

diff --git a/http.c b/http.c
index 9b15c6c012e478cd43badacb203cdffc2ac734b4..75ca08854053cb51c9671f3e59697eaa05ef32f9 100644 (file)
--- 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
index 811acba2f6dc3470459d72b9f3dfed5b2269a3ca..285c030836bc8ef2c6c3b1d80b06c19967d6b802 100644 (file)
@@ -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); \
index 1c63ba0d6b270f57dbe2a01a28d012e44b98fb59..b1e2256c6ab72dc129a2454ee39786c7776d10e9 100644 (file)
@@ -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)) {
index dab3dae504c61de0a75294d2262461faa23734fb..299a5616e83453b3fb151ab4dd081d9aa878bacd 100644 (file)
@@ -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.
  */
index 46b805a262b9e26746eccbd34408a0b3ad1acd08..8c4bc0ef0a8edf7510fb5adcf3119540e7989e20 100644 (file)
@@ -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);
index aef44909d8ca22f24eb4b7562143da84710eccec..579ea352f7e7d61ca83d8deb47e63caa9e001962 100644 (file)
@@ -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);
index 1b3d3bc1107020447bc11c684620ff055c28e6c3..2e575a38d86bc6f9c339c049f7fa44e976050dbe 100644 (file)
@@ -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)