diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2005-08-31 01:19:40 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2005-08-31 01:19:40 +0000 |
commit | 50fb7a8261ce1b68513f7fe6d4623b80fb36bb5c (patch) | |
tree | 3d3762b6f753ebfa731862e556b9e168b44c23f1 | |
parent | 4f1520912cb8f905edb1b6c5a81260ad71569699 (diff) | |
download | php-git-50fb7a8261ce1b68513f7fe6d4623b80fb36bb5c.tar.gz |
Added optional parameter to http_build_query() to allow specification of
string separator.
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | ext/standard/http.c | 25 | ||||
-rw-r--r-- | ext/standard/php_http.h | 2 |
3 files changed, 17 insertions, 12 deletions
@@ -4,6 +4,8 @@ PHP NEWS - Unicode support. (Andrei, Dmitriy, et al) - Changed "instanceof" operator, is_a() and is_subclass_of() functions to not call __autoload(). (Dmitry) +- Added optional parameter to http_build_query() to allow specification of + string separator. - cURL improvements: (Ilia) . Added curl_setopt_array() which allows setting of multiple cURL options. . Added CURLINFO_HEADER_OUT to facilitate request retrieval. diff --git a/ext/standard/http.c b/ext/standard/http.c index 6032a13cf6..65a482b1bb 100644 --- a/ext/standard/http.c +++ b/ext/standard/http.c @@ -29,9 +29,9 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, const char *num_prefix, int num_prefix_len, const char *key_prefix, int key_prefix_len, const char *key_suffix, int key_suffix_len, - zval *type TSRMLS_DC) + zval *type, char *arg_sep TSRMLS_DC) { - char *arg_sep = NULL, *key = NULL, *ekey, *newprefix, *p; + char *key = NULL, *ekey, *newprefix, *p; int arg_sep_len, key_len, ekey_len, key_type, newprefix_len; ulong idx; zval **zdata = NULL, *copyzval; @@ -45,9 +45,11 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, return SUCCESS; } - arg_sep = INI_STR("arg_separator.output"); - if (!arg_sep || !strlen(arg_sep)) { - arg_sep = URL_DEFAULT_ARG_SEP; + if (!arg_sep) { + arg_sep = INI_STR("arg_separator.output"); + if (!arg_sep || !strlen(arg_sep)) { + arg_sep = URL_DEFAULT_ARG_SEP; + } } arg_sep_len = strlen(arg_sep); @@ -127,7 +129,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, *p = '\0'; } ht->nApplyCount++; - php_url_encode_hash_ex(HASH_OF(*zdata), formstr, NULL, 0, newprefix, newprefix_len, "]", 1, (Z_TYPE_PP(zdata) == IS_OBJECT ? *zdata : NULL) TSRMLS_CC); + php_url_encode_hash_ex(HASH_OF(*zdata), formstr, NULL, 0, newprefix, newprefix_len, "]", 1, (Z_TYPE_PP(zdata) == IS_OBJECT ? *zdata : NULL), arg_sep TSRMLS_CC); ht->nApplyCount--; efree(newprefix); } else if (Z_TYPE_PP(zdata) == IS_NULL || Z_TYPE_PP(zdata) == IS_RESOURCE) { @@ -183,16 +185,17 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, } /* }}} */ -/* {{{ proto string http_build_query(mixed formdata [, string prefix]) +/* {{{ proto string http_build_query(mixed formdata [, string prefix [, string arg_separator]]) Generates a form-encoded query string from an associative array or object. */ PHP_FUNCTION(http_build_query) { zval *formdata; - char *prefix = NULL; - int prefix_len = 0; + char *prefix = NULL, *arg_sep=NULL; + int arg_sep_len, prefix_len = 0; smart_str formstr = {0}; + - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|s", &formdata, &prefix, &prefix_len) != SUCCESS) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|ss", &formdata, &prefix, &prefix_len, &arg_sep, &arg_sep_len) != SUCCESS) { RETURN_FALSE; } @@ -201,7 +204,7 @@ PHP_FUNCTION(http_build_query) RETURN_FALSE; } - if (php_url_encode_hash_ex(HASH_OF(formdata), &formstr, prefix, prefix_len, NULL, 0, NULL, 0, (Z_TYPE_P(formdata) == IS_OBJECT ? formdata : NULL) TSRMLS_CC) == FAILURE) { + if (php_url_encode_hash_ex(HASH_OF(formdata), &formstr, prefix, prefix_len, NULL, 0, NULL, 0, (Z_TYPE_P(formdata) == IS_OBJECT ? formdata : NULL), arg_sep TSRMLS_CC) == FAILURE) { if (formstr.c) { efree(formstr.c); } diff --git a/ext/standard/php_http.h b/ext/standard/php_http.h index d221191662..a2de9dc59f 100644 --- a/ext/standard/php_http.h +++ b/ext/standard/php_http.h @@ -28,7 +28,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, const char *num_prefix, int num_prefix_len, const char *key_prefix, int key_prefix_len, const char *key_suffix, int key_suffix_len, - zval *type TSRMLS_DC); + zval *type, char *arg_sep TSRMLS_DC); #define php_url_encode_hash(ht, formstr) php_url_encode_hash_ex((ht), (formstr), NULL, 0, NULL, 0, NULL, 0, NULL TSRMLS_CC) PHP_FUNCTION(http_build_query); |