From 4f9f3e9032252995b600ed4c4ea538e6302730a2 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Mon, 2 Mar 2015 15:58:58 +0100 Subject: [PATCH] remove rinit and json dep in favor of pecl/json_post and pecl/apfd --- config9.m4 | 7 --- package.xml | 7 +-- php_http.c | 17 +------ php_http_api.h | 4 -- php_http_env.c | 118 ------------------------------------------------- php_http_env.h | 1 - 6 files changed, 3 insertions(+), 151 deletions(-) diff --git a/config9.m4 b/config9.m4 index ec202b6..0e5e1ce 100644 --- a/config9.m4 +++ b/config9.m4 @@ -510,12 +510,6 @@ dnl ---- fi ]) -dnl ---- -dnl JSON -dnl ---- - HTTP_HAVE_PHP_EXT([json]) - - dnl ---- dnl ICONV dnl ---- @@ -560,7 +554,6 @@ dnl ---- dnl shared extension deps HTTP_SHARED_DEP([hash]) HTTP_SHARED_DEP([iconv]) - HTTP_SHARED_DEP([json]) dnl extension deps PHP_ADD_EXTENSION_DEP([http], [raphf], true) diff --git a/package.xml b/package.xml index c406bca..447de8a 100644 --- a/package.xml +++ b/package.xml @@ -23,12 +23,10 @@ It provides powerful request functionality with support for parallel requests. Documentation: -v1: http://php.net/http -v2: http://devel-m6w6.rhcloud.com/mdref/http +http://devel-m6w6.rhcloud.com/mdref/http Code Coverage: -v1: http://dev.iworks.at/ext-http/lcov_html/ext/http/ -v2: http://dev.iworks.at/ext-http/lcov/ext/http/ +http://dev.iworks.at/ext-http/lcov/ext/http/ ]]> @@ -349,7 +347,6 @@ v2: http://dev.iworks.at/ext-http/lcov/ext/http/ hash iconv - json http diff --git a/php_http.c b/php_http.c index 17d9925..bd7baff 100644 --- a/php_http.c +++ b/php_http.c @@ -44,7 +44,6 @@ zend_function_entry http_functions[] = { PHP_MINIT_FUNCTION(http); PHP_MSHUTDOWN_FUNCTION(http); -PHP_RINIT_FUNCTION(http); PHP_RSHUTDOWN_FUNCTION(http); PHP_MINFO_FUNCTION(http); @@ -57,9 +56,6 @@ static zend_module_dep http_module_deps[] = { #endif #ifdef PHP_HTTP_HAVE_ICONV ZEND_MOD_REQUIRED("iconv") -#endif -#ifdef PHP_HTTP_HAVE_JSON - ZEND_MOD_REQUIRED("json") #endif {NULL, NULL, NULL, 0} }; @@ -72,7 +68,7 @@ zend_module_entry http_module_entry = { http_functions, PHP_MINIT(http), PHP_MSHUTDOWN(http), - PHP_RINIT(http), + NULL, PHP_RSHUTDOWN(http), PHP_MINFO(http), PHP_PECL_HTTP_VERSION, @@ -185,17 +181,6 @@ PHP_MSHUTDOWN_FUNCTION(http) return SUCCESS; } -PHP_RINIT_FUNCTION(http) -{ - if (0 - || SUCCESS != PHP_RINIT_CALL(http_env) - ) { - return FAILURE; - } - - return SUCCESS; -} - PHP_RSHUTDOWN_FUNCTION(http) { if (0 diff --git a/php_http_api.h b/php_http_api.h index 00a09ae..ec18293 100644 --- a/php_http_api.h +++ b/php_http_api.h @@ -52,10 +52,6 @@ typedef int STATUS; # define PHP_HTTP_HAVE_HASH #endif -#if (defined(HAVE_JSON) || defined(PHP_HTTP_HAVE_EXT_JSON)) && (PHP_HTTP_SHARED_DEPS || !defined(COMPILE_DL_JSON)) -# define PHP_HTTP_HAVE_JSON -#endif - #include #ifdef PHP_WIN32 diff --git a/php_http_env.c b/php_http_env.c index 6de5ecb..f06769c 100644 --- a/php_http_env.c +++ b/php_http_env.c @@ -13,68 +13,6 @@ #include "php_http_api.h" #include "php_variables.h" -PHP_RINIT_FUNCTION(http_env) -{ - /* populate form data on non-POST requests */ - if (SG(request_info).request_method && strcasecmp(SG(request_info).request_method, "POST") && SG(request_info).content_type && *SG(request_info).content_type) { - uint ct_len = strlen(SG(request_info).content_type); - char *ct_str = estrndup(SG(request_info).content_type, ct_len); - php_http_params_opts_t opts; - HashTable params; - - php_http_params_opts_default_get(&opts); - opts.input.str = ct_str; - opts.input.len = ct_len; - - SG(request_info).content_type_dup = ct_str; - - ZEND_INIT_SYMTABLE(¶ms); - if (php_http_params_parse(¶ms, &opts TSRMLS_CC)) { - char *key_str; - uint key_len; - ulong key_num; - - if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(¶ms, &key_str, &key_len, &key_num, 0, NULL)) { - sapi_post_entry *post_entry = NULL; - - if (SUCCESS == zend_hash_find(&SG(known_post_content_types), key_str, key_len, (void *) &post_entry)) { - zval *files = PG(http_globals)[TRACK_VARS_FILES]; - - if (post_entry) { - SG(request_info).post_entry = post_entry; - - if (post_entry->post_reader) { - post_entry->post_reader(TSRMLS_C); - } - } - - if (sapi_module.default_post_reader) { - sapi_module.default_post_reader(TSRMLS_C); - } - - sapi_handle_post(PG(http_globals)[TRACK_VARS_POST] TSRMLS_CC); - - /* - * the rfc1867 handler is an awkward buddy - */ - if (files != PG(http_globals)[TRACK_VARS_FILES] && PG(http_globals)[TRACK_VARS_FILES]) { - Z_ADDREF_P(PG(http_globals)[TRACK_VARS_FILES]); - zend_hash_update(&EG(symbol_table), "_FILES", sizeof("_FILES"), &PG(http_globals)[TRACK_VARS_FILES], sizeof(zval *), NULL); - if (files) { - zval_ptr_dtor(&files); - } - } - } - } - zend_hash_destroy(¶ms); - } - } - - PTR_SET(SG(request_info).content_type_dup, NULL); - - return SUCCESS; -} - PHP_RSHUTDOWN_FUNCTION(http_env) { if (PHP_HTTP_G->env.request.headers) { @@ -858,58 +796,6 @@ static zend_function_entry php_http_env_methods[] = { EMPTY_FUNCTION_ENTRY }; -#ifdef PHP_HTTP_HAVE_JSON -#include "ext/json/php_json.h" - -static SAPI_POST_HANDLER_FUNC(php_http_json_post_handler) -{ - zval *zarg = arg; - char *json_str = NULL; - size_t json_len = 0; - -#if PHP_VERSION_ID >= 50600 - if (SG(request_info).request_body) { - /* FG(stream_wrappers) not initialized yet, so we cannot use php://input */ - php_stream_rewind(SG(request_info).request_body); - json_len = php_stream_copy_to_mem(SG(request_info).request_body, &json_str, PHP_STREAM_COPY_ALL, 0); - } -#else - json_str = SG(request_info).raw_post_data; - json_len = SG(request_info).raw_post_data_length; -#endif - - if (json_len) { - zval zjson; - - INIT_ZVAL(zjson); - php_json_decode(&zjson, json_str, json_len, 1, PG(max_input_nesting_level) TSRMLS_CC); - if (Z_TYPE(zjson) != IS_NULL) { - zval_dtor(zarg); - ZVAL_COPY_VALUE(zarg, (&zjson)); - } - } -#if PHP_VERSION_ID >= 50600 - PTR_FREE(json_str); -#endif -} - -static void php_http_env_register_json_handler(TSRMLS_D) -{ - sapi_post_entry entry = {NULL, 0, NULL, NULL}; - - entry.post_reader = sapi_read_standard_form_data; - entry.post_handler = php_http_json_post_handler; - - entry.content_type = "text/json"; - entry.content_type_len = lenof("text/json"); - sapi_register_post_entry(&entry TSRMLS_CC); - - entry.content_type = "application/json"; - entry.content_type_len = lenof("application/json"); - sapi_register_post_entry(&entry TSRMLS_CC); -} -#endif - zend_class_entry *php_http_env_class_entry; PHP_MINIT_FUNCTION(http_env) @@ -919,10 +805,6 @@ PHP_MINIT_FUNCTION(http_env) INIT_NS_CLASS_ENTRY(ce, "http", "Env", php_http_env_methods); php_http_env_class_entry = zend_register_internal_class(&ce TSRMLS_CC); -#ifdef PHP_HTTP_HAVE_JSON - php_http_env_register_json_handler(TSRMLS_C); -#endif - return SUCCESS; } diff --git a/php_http_env.h b/php_http_env.h index 7556c3e..3b8d87f 100644 --- a/php_http_env.h +++ b/php_http_env.h @@ -73,7 +73,6 @@ PHP_HTTP_API zval *php_http_env_get_superglobal(const char *key, size_t key_len PHP_HTTP_API zend_class_entry *php_http_env_class_entry; PHP_MINIT_FUNCTION(http_env); -PHP_RINIT_FUNCTION(http_env); PHP_RSHUTDOWN_FUNCTION(http_env); #endif -- 2.30.2