X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=http_request_api.c;h=d96c1808a9fb4d68b4c02ea4c8230f7786095e97;hb=b2e9ffe535660f5de2ec850ddc0dd6e99a34724d;hp=260b1f4a89fa065f02a674fc0bf2c4e11d9ffbeb;hpb=0c20f7c9ead5ddda3f386361932438fe96283da0;p=m6w6%2Fext-http diff --git a/http_request_api.c b/http_request_api.c index 260b1f4..d96c180 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 @@ -224,7 +222,7 @@ PHP_HTTP_API http_request *_http_request_init_ex(http_request *request, CURL *ch memset(r, 0, sizeof(http_request)); r->ch = ch; - r->url = (url && *url) ? estrdup(url) : NULL; + r->url = (url) ? http_absolute_url(url) : NULL; r->meth = (meth > 0) ? meth : HTTP_GET; phpstr_init(&r->conv.request); @@ -495,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");