}
#endif
#endif
-PHP_INI_MH(http_update_persistent_handle_ident)
-{
- PHP_HTTP_G->persistent_handle.ident.h = zend_hash_func(new_value, PHP_HTTP_G->persistent_handle.ident.l = new_value_length+1);
- return OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
-}
-
PHP_INI_BEGIN()
PHP_HTTP_INI_ENTRY("http.etag.mode", "md5", PHP_INI_ALL, OnUpdateString, env.etag_mode)
PHP_HTTP_INI_ENTRY("http.request_datashare.cookie", "0", PHP_INI_SYSTEM, OnUpdateBool, request_datashare.cookie)
PHP_HTTP_INI_ENTRY("http.request_datashare.ssl", "0", PHP_INI_SYSTEM, OnUpdateBool, request_datashare.ssl)
PHP_HTTP_INI_ENTRY("http.request_datashare.connect", "0", PHP_INI_SYSTEM, OnUpdateBool, request_datashare.connect)
PHP_HTTP_INI_ENTRY("http.persistent_handle.limit", "-1", PHP_INI_SYSTEM, OnUpdateLong, persistent_handle.limit)
- PHP_HTTP_INI_ENTRY("http.persistent_handle.ident", "GLOBAL", PHP_INI_ALL, http_update_persistent_handle_ident, persistent_handle.ident.s)
PHP_INI_END()
PHP_MINIT_FUNCTION(http)
zval *urlenc_cookies = NULL;
/* check whether cookies should not be urlencoded; default is to urlencode them */
if ((!(urlenc_cookies = get_option(&curl->options.cache, options, ZEND_STRS("encodecookies"), IS_BOOL))) || Z_BVAL_P(urlenc_cookies)) {
- if (SUCCESS == php_http_url_encode_hash_recursive(HASH_OF(zoption), &curl->options.cookies, "; ", lenof("; "), NULL, 0 TSRMLS_CC)) {
+ if (SUCCESS == php_http_url_encode_hash_ex(HASH_OF(zoption), &curl->options.cookies, ZEND_STRS(";"), ZEND_STRS("="), NULL, 0 TSRMLS_CC)) {
php_http_buffer_fix(&curl->options.cookies);
curl_easy_setopt(ch, CURLOPT_COOKIE, curl->options.cookies.data);
}
PHP_HTTP_ARG_VAL(name, 0)
PHP_HTTP_END_ARGS;
+PHP_HTTP_BEGIN_ARGS(parseParams, 1)
+ PHP_HTTP_ARG_VAL(params, 0)
+ PHP_HTTP_ARG_VAL(flags, 0)
+PHP_HTTP_END_ARGS;
+
zend_function_entry php_http_env_method_entry[] = {
PHP_HTTP_ENV_ME(getRequestHeader)
PHP_HTTP_ENV_ME(getRequestBody)
PHP_HTTP_ENV_ME(persistentHandlesStat)
PHP_HTTP_ENV_ME(persistentHandlesClean)
+ PHP_HTTP_ENV_ME(parseParams)
+
EMPTY_FUNCTION_ENTRY
};
}
}
+PHP_METHOD(HttpEnv, parseParams)
+{
+ char *param_str;
+ int param_len;
+ long flags = PHP_HTTP_PARAMS_DEFAULT;
+
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", ¶m_str, ¶m_len, &flags)) {
+ RETURN_FALSE;
+ }
+
+ array_init(return_value);
+ if (SUCCESS != php_http_params_parse(param_str, flags, php_http_params_parse_default_func, Z_ARRVAL_P(return_value) TSRMLS_CC)) {
+ zval_dtor(return_value);
+ RETURN_FALSE;
+ }
+}
+
zend_class_entry *php_http_env_request_class_entry;
#undef PHP_HTTP_BEGIN_ARGS
PHP_MINIT_FUNCTION(http_env)
{
PHP_HTTP_REGISTER_CLASS(http, Env, http_env, NULL, 0);
+
+ zend_declare_class_constant_long(php_http_env_class_entry, ZEND_STRL("PARAMS_ALLOW_COMMA"), PHP_HTTP_PARAMS_ALLOW_COMMA TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_env_class_entry, ZEND_STRL("PARAMS_ALLOW_FAILURE"), PHP_HTTP_PARAMS_ALLOW_FAILURE TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_env_class_entry, ZEND_STRL("PARAMS_RAISE_ERROR"), PHP_HTTP_PARAMS_RAISE_ERROR TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_env_class_entry, ZEND_STRL("PARAMS_DEFAULT"), PHP_HTTP_PARAMS_DEFAULT TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_env_class_entry, ZEND_STRL("PARAMS_COLON_SEPARATOR"), PHP_HTTP_PARAMS_COLON_SEPARATOR TSRMLS_CC);
+
PHP_HTTP_REGISTER_CLASS(http\\env, Request, http_env_request, php_http_message_class_entry, 0);
return SUCCESS;
PHP_METHOD(HttpEnv, negotiate);
PHP_METHOD(HttpEnv, persistentHandlesStat);
PHP_METHOD(HttpEnv, persistentHandlesClean);
+PHP_METHOD(HttpEnv, parseParams);
extern zend_class_entry *php_http_env_request_class_entry;
extern zend_function_entry php_http_env_request_method_entry[];
/* check whether cookies should not be urlencoded; default is to urlencode them */
if ((!(urlenc_cookies = get_option(&neon->options.cache, options, ZEND_STRS("encodecookies"), IS_BOOL))) || Z_BVAL_P(urlenc_cookies)) {
- php_http_url_encode_hash_recursive(HASH_OF(zoption), &neon->options.headers, "; ", lenof("; "), NULL, 0 TSRMLS_CC);
+ php_http_url_encode_hash_ex(HASH_OF(zoption), &neon->options.headers, ZEND_STRS("; "), ZEND_STRS("="), NULL, 0 TSRMLS_CC);
} else {
HashPosition pos;
php_http_array_hashkey_t cookie_key = php_http_array_hashkey_init(0);
char *s;
size_t l;
- if (SUCCESS == php_http_url_encode_hash(Z_ARRVAL_P(qarray), 0, NULL, 0, &s, &l TSRMLS_CC)) {
+ if (SUCCESS == php_http_url_encode_hash(Z_ARRVAL_P(qarray), NULL, 0, &s, &l TSRMLS_CC)) {
zval_dtor(outstring);
ZVAL_STRINGL(outstring, s, l, 0);
} else {
char *query_data_str = NULL;
size_t query_data_len;
- if (SUCCESS == php_http_url_encode_hash(HASH_OF(qdata), 0, NULL, 0, &query_data_str, &query_data_len TSRMLS_CC)) {
+ if (SUCCESS == php_http_url_encode_hash(HASH_OF(qdata), NULL, 0, &query_data_str, &query_data_len TSRMLS_CC)) {
zend_update_property_stringl(php_http_request_class_entry, getThis(), ZEND_STRL("queryData"), query_data_str, query_data_len TSRMLS_CC);
efree(query_data_str);
}
size_t query_data_len = 0;
zval *old_qdata = zend_read_property(php_http_request_class_entry, getThis(), ZEND_STRL("queryData"), 0 TSRMLS_CC);
- if (SUCCESS == php_http_url_encode_hash(HASH_OF(qdata), 1, Z_STRVAL_P(old_qdata), Z_STRLEN_P(old_qdata), &query_data_str, &query_data_len TSRMLS_CC)) {
+ if (SUCCESS == php_http_url_encode_hash(HASH_OF(qdata), Z_STRVAL_P(old_qdata), Z_STRLEN_P(old_qdata), &query_data_str, &query_data_len TSRMLS_CC)) {
zend_update_property_stringl(php_http_request_class_entry, getThis(), ZEND_STRL("queryData"), query_data_str, query_data_len TSRMLS_CC);
efree(query_data_str);
}
}
}
-PHP_HTTP_API STATUS php_http_url_encode_hash(HashTable *hash, zend_bool override_argsep, char *pre_encoded_data, size_t pre_encoded_len, char **encoded_data, size_t *encoded_len TSRMLS_DC)
+PHP_HTTP_API STATUS php_http_url_encode_hash(HashTable *hash, const char *pre_encoded_str, size_t pre_encoded_len, char **encoded_str, size_t *encoded_len TSRMLS_DC)
{
- char *arg_sep;
+ const char *arg_sep_str;
size_t arg_sep_len;
php_http_buffer_t *qstr = php_http_buffer_new();
- if (override_argsep || !(arg_sep_len = strlen(arg_sep = INI_STR("arg_separator.output")))) {
- arg_sep = PHP_HTTP_URL_ARGSEP;
- arg_sep_len = lenof(PHP_HTTP_URL_ARGSEP);
- }
+ php_http_url_argsep(&arg_sep_str, &arg_sep_len TSRMLS_CC);
- if (pre_encoded_len && pre_encoded_data) {
- php_http_buffer_append(qstr, pre_encoded_data, pre_encoded_len);
+ if (pre_encoded_len && pre_encoded_str) {
+ php_http_buffer_append(qstr, pre_encoded_str, pre_encoded_len);
}
- if (SUCCESS != php_http_url_encode_hash_recursive(hash, qstr, arg_sep, arg_sep_len, NULL, 0 TSRMLS_CC)) {
+ if (SUCCESS != php_http_url_encode_hash_ex(hash, qstr, arg_sep_str, arg_sep_len, ZEND_STRS("="), NULL, 0 TSRMLS_CC)) {
php_http_buffer_free(&qstr);
return FAILURE;
}
- php_http_buffer_data(qstr, encoded_data, encoded_len);
+ php_http_buffer_data(qstr, encoded_str, encoded_len);
php_http_buffer_free(&qstr);
return SUCCESS;
}
-PHP_HTTP_API STATUS php_http_url_encode_hash_recursive(HashTable *ht, php_http_buffer_t *str, const char *arg_sep, size_t arg_sep_len, const char *prefix, size_t prefix_len TSRMLS_DC)
+PHP_HTTP_API STATUS php_http_url_encode_hash_ex(HashTable *ht, php_http_buffer_t *str, const char *arg_sep_str, size_t arg_sep_len, const char *val_sep_str, size_t val_sep_len, const char *prefix_str, size_t prefix_len TSRMLS_DC)
{
php_http_array_hashkey_t key = php_http_array_hashkey_init(0);
zval **data = NULL;
{
php_http_buffer_init(&new_prefix);
- if (prefix && prefix_len) {
- php_http_buffer_append(&new_prefix, prefix, prefix_len);
+ if (prefix_str && prefix_len) {
+ php_http_buffer_append(&new_prefix, prefix_str, prefix_len);
php_http_buffer_appends(&new_prefix, "%5B");
}
php_http_buffer_append(&new_prefix, encoded_key, encoded_len);
efree(encoded_key);
- if (prefix && prefix_len) {
+ if (prefix_str && prefix_len) {
php_http_buffer_appends(&new_prefix, "%5D");
}
php_http_buffer_fix(&new_prefix);
if (Z_TYPE_PP(data) == IS_ARRAY || Z_TYPE_PP(data) == IS_OBJECT) {
STATUS status;
++ht->nApplyCount;
- status = php_http_url_encode_hash_recursive(HASH_OF(*data), str, arg_sep, arg_sep_len, PHP_HTTP_BUFFER_VAL(&new_prefix), PHP_HTTP_BUFFER_LEN(&new_prefix) TSRMLS_CC);
+ status = php_http_url_encode_hash_ex(HASH_OF(*data), str, arg_sep_str, arg_sep_len, val_sep_str, val_sep_len, PHP_HTTP_BUFFER_VAL(&new_prefix), PHP_HTTP_BUFFER_LEN(&new_prefix) TSRMLS_CC);
--ht->nApplyCount;
if (SUCCESS != status) {
php_http_buffer_dtor(&new_prefix);
zval *val = php_http_ztyp(IS_STRING, *data);
if (PHP_HTTP_BUFFER_LEN(str)) {
- php_http_buffer_append(str, arg_sep, arg_sep_len);
+ php_http_buffer_append(str, arg_sep_str, arg_sep_len);
}
php_http_buffer_append(str, PHP_HTTP_BUFFER_VAL(&new_prefix), PHP_HTTP_BUFFER_LEN(&new_prefix));
- php_http_buffer_appends(str, "=");
+ php_http_buffer_append(str, val_sep_str, val_sep_len);
if (Z_STRLEN_P(val) && Z_STRVAL_P(val)) {
char *encoded_val;
PHP_HTTP_API void php_http_url(int flags, const php_url *old_url, const php_url *new_url, php_url **url_ptr, char **url_str, size_t *url_len TSRMLS_DC);
PHP_HTTP_API char *php_http_url_absolute(const char *url, int flags TSRMLS_DC);
-PHP_HTTP_API STATUS php_http_url_encode_hash(HashTable *hash, zend_bool override_argsep, char *pre_encoded_data, size_t pre_encoded_len, char **encoded_data, size_t *encoded_len TSRMLS_DC);
-PHP_HTTP_API STATUS php_http_url_encode_hash_recursive(HashTable *ht, php_http_buffer_t *str, const char *arg_sep, size_t arg_sep_len, const char *prefix, size_t prefix_len TSRMLS_DC);
+PHP_HTTP_API STATUS php_http_url_encode_hash(HashTable *hash, const char *pre_encoded_str, size_t pre_encoded_len, char **encoded_str, size_t *encoded_len TSRMLS_DC);
+PHP_HTTP_API STATUS php_http_url_encode_hash_ex(HashTable *ht, php_http_buffer_t *str, const char *arg_sep_str, size_t arg_sep_len, const char *val_sep_str, size_t val_sep_len, const char *prefix_str, size_t prefix_len TSRMLS_DC);
+
+static inline void php_http_url_argsep(const char **str, size_t *len TSRMLS_DC)
+{
+ *str = INI_STR("arg_separator.output");
+ *len = strlen(*str);
+
+ if (!*len) {
+ *str = PHP_HTTP_URL_ARGSEP;
+ *len = lenof(PHP_HTTP_URL_ARGSEP);
+ }
+}
static inline php_url *php_http_url_from_struct(php_url *url, HashTable *ht TSRMLS_DC)
{