X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_request_api.c;h=f6ee54eb50bdf04dd0b3d171857a40fb2ea66bf2;hp=85144807f1b6a9e489eb2c7b9d9cbad529059c1b;hb=7b88d9022c90eb12e5fe195af8644935141c9d68;hpb=1041b48ef546c1a99f9a94210c19bcab364673cd diff --git a/http_request_api.c b/http_request_api.c index 8514480..f6ee54e 100644 --- a/http_request_api.c +++ b/http_request_api.c @@ -29,8 +29,6 @@ # include "php_http_request_object.h" #endif -ZEND_EXTERN_MODULE_GLOBALS(http); - /* {{{ cruft for thread safe SSL crypto locks */ #if defined(ZTS) && defined(HTTP_HAVE_SSL) # ifdef PHP_WIN32 @@ -471,12 +469,16 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti zval **header_val; if (SUCCESS == zend_hash_get_current_data_ex(Z_ARRVAL_P(zoption), (void **) &header_val, &pos)) { char header[1024] = {0}; + zval val; - SEPARATE_ZVAL(header_val); - convert_to_string(*header_val); + val = **header_val; + zval_copy_ctor(&val); + INIT_PZVAL(&val); + convert_to_string(&val); - snprintf(header, 1023, "%s: %s", header_key, Z_STRVAL_PP(header_val)); + snprintf(header, 1023, "%s: %s", header_key, Z_STRVAL(val)); request->_cache.headers = curl_slist_append(request->_cache.headers, header); + zval_dtor(&val); } /* reset */ @@ -491,37 +493,14 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti /* cookies, array('name' => 'value') */ if ((zoption = http_request_option(request, options, "cookies", IS_ARRAY))) { - char *cookie_key = NULL; - ulong cookie_idx = 0; - HashPosition pos; - phpstr_dtor(&request->_cache.cookies); - - FOREACH_KEY(pos, zoption, cookie_key, cookie_idx) { - if (cookie_key) { - zval **cookie_val; - if (SUCCESS == zend_hash_get_current_data_ex(Z_ARRVAL_P(zoption), (void **) &cookie_val, &pos)) { - zval *cpy, *val = convert_to_type_ex(IS_STRING, *cookie_val, &cpy); - - phpstr_appendf(&request->_cache.cookies, "%s=%s; ", cookie_key, Z_STRVAL_P(val)); - - if (cpy) { - zval_ptr_dtor(&cpy); - } - } - - /* reset */ - cookie_key = NULL; - } - } - - if (request->_cache.cookies.used) { + if (SUCCESS == http_urlencode_hash_recursive(HASH_OF(zoption), &request->_cache.cookies, "; ", sizeof("; ")-1, NULL, 0)) { phpstr_fix(&request->_cache.cookies); HTTP_CURL_OPT(COOKIE, request->_cache.cookies.data); } } -#if LIBCURL_VERSIONNUM >= 0x070f01 +#if LIBCURL_VERSION_NUM >= 0x070f01 /* reset cookies */ if ((zoption = http_request_option(request, options, "resetcookies", IS_BOOL)) && Z_LVAL_P(zoption)) { HTTP_CURL_OPT(COOKIELIST, "ALL");