X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_request_api.c;h=26b4b0992cccd8db395c8cb3e772823b4c5d8ca8;hp=fd1a176f9f7805488a694d271f2f466956ef6394;hb=767eb5781e4d072f496b5f1009024602f9bd5651;hpb=e577961fed4b5ae6a868adbeb420e0fec7aa8c6e diff --git a/http_request_api.c b/http_request_api.c index fd1a176..26b4b09 100644 --- a/http_request_api.c +++ b/http_request_api.c @@ -471,14 +471,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 *cpy, *val = convert_to_type_ex(IS_STRING, *header_val, &cpy); + zval val; - snprintf(header, 1023, "%s: %s", header_key, Z_STRVAL_P(val)); - request->_cache.headers = curl_slist_append(request->_cache.headers, header); + val = **header_val; + zval_copy_ctor(&val); + INIT_PZVAL(&val); + convert_to_string(&val); - if (cpy) { - zval_ptr_dtor(&cpy); - } + snprintf(header, 1023, "%s: %s", header_key, Z_STRVAL(val)); + request->_cache.headers = curl_slist_append(request->_cache.headers, header); + zval_dtor(&val); } /* reset */ @@ -503,13 +505,16 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti 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); + zval val; - phpstr_appendf(&request->_cache.cookies, "%s=%s; ", cookie_key, Z_STRVAL_P(val)); + val = **cookie_val; + INIT_PZVAL(&val); + zval_copy_ctor(&val); + convert_to_string(&val); - if (cpy) { - zval_ptr_dtor(&cpy); - } + phpstr_appendf(&request->_cache.cookies, "%s=%s; ", cookie_key, Z_STRVAL(val)); + + zval_dtor(&val); } /* reset */ @@ -523,6 +528,13 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti } } +#if LIBCURL_VERSIONNUM >= 0x070f01 + /* reset cookies */ + if ((zoption = http_request_option(request, options, "resetcookies", IS_BOOL)) && Z_LVAL_P(zoption)) { + HTTP_CURL_OPT(COOKIELIST, "ALL"); + } +#endif + /* session cookies */ if ((zoption = http_request_option(request, options, "cookiesession", IS_BOOL))) { if (Z_LVAL_P(zoption)) {