X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=php_http_curl.c;h=5fea9fea4f864a06baf78124bcc1ca5d8a442860;hb=737776929a44884a24c3e584162d771ada71f7e9;hp=71365dc04ea89d99c56cba0e5d75d793fb64fb6d;hpb=7dc5de0b79846bfe33ca36a9eeb894ef2ecfdee1;p=m6w6%2Fext-http diff --git a/php_http_curl.c b/php_http_curl.c index 71365dc..5fea9fe 100644 --- a/php_http_curl.c +++ b/php_http_curl.c @@ -1,19 +1,26 @@ - -#include "php_http.h" -#include "php_http_request.h" -#include "php_http_request_pool.h" +/* + +--------------------------------------------------------------------+ + | PECL :: http | + +--------------------------------------------------------------------+ + | Redistribution and use in source and binary forms, with or without | + | modification, are permitted provided that the conditions mentioned | + | in the accompanying LICENSE file are met. | + +--------------------------------------------------------------------+ + | Copyright (c) 2004-2011, Michael Wallner | + +--------------------------------------------------------------------+ +*/ + +#include "php_http_api.h" + +#if PHP_HTTP_HAVE_CURL #include #define PHP_HTTP_CURL_VERSION(x, y, z) (LIBCURL_VERSION_NUM >= (((x)<<16) + ((y)<<8) + (z))) -#ifdef PHP_HTTP_HAVE_EVENT +#if PHP_HTTP_HAVE_EVENT # include #endif -#include -#include - - typedef struct php_http_curl_request { CURL *handle; @@ -21,6 +28,7 @@ typedef struct php_http_curl_request { HashTable cache; struct curl_slist *headers; + struct curl_slist *resolve; php_http_buffer_t cookies; long redirects; @@ -47,26 +55,15 @@ typedef struct php_http_curl_request_pool { int unfinished; /* int because of curl_multi_perform() */ -#ifdef PHP_HTTP_HAVE_EVENT +#if PHP_HTTP_HAVE_EVENT struct event *timeout; unsigned useevents:1; unsigned runsocket:1; #endif } php_http_curl_request_pool_t; -#ifdef ZTS -typedef struct php_http_curl_request_datashare_lock { - CURL *ch; - MUTEX_T mx; -} php_http_curl_request_datashare_lock_t; -#endif - typedef struct php_http_curl_request_datashare { CURLSH *handle; - -#ifdef ZTS - php_http_curl_request_datashare_lock_t *locks; -#endif } php_http_curl_request_datashare_t; #define PHP_HTTP_CURL_OPT_STRING(OPTION, ldiff, obdc) \ @@ -131,6 +128,7 @@ static void *php_http_curl_copy(void *opaque, void *handle TSRMLS_DC) void *ch; if ((ch = curl_easy_duphandle(handle))) { + curl_easy_reset(ch); get_storage(ch); return ch; } @@ -227,6 +225,7 @@ static int php_http_curl_raw_callback(CURL *ch, curl_infotype type, char *data, php_http_request_t *h = ctx; php_http_curl_request_t *curl = h->ctx; unsigned flags = 0; + TSRMLS_FETCH_FROM_CTX(h->ts); /* catch progress */ switch (type) { @@ -241,6 +240,8 @@ static int php_http_curl_raw_callback(CURL *ch, curl_infotype type, char *data, curl->progress.state.info = "not disconnected"; } else if (php_memnstr(data, ZEND_STRL("closed"), data + length)) { curl->progress.state.info = "disconnected"; + } else if (php_memnstr(data, ZEND_STRL("Issue another request"), data + length)) { + curl->progress.state.info = "redirect"; } php_http_request_progress_notify(&curl->progress TSRMLS_CC); break; @@ -290,7 +291,7 @@ static int php_http_curl_dummy_callback(char *data, size_t n, size_t l, void *s) return n*l; } -static STATUS php_http_curl_request_prepare(php_http_request_t *h, php_http_request_method_t meth, const char *url, php_http_message_body_t *body) +static STATUS php_http_curl_request_prepare(php_http_request_t *h, const char *meth, const char *url, php_http_message_body_t *body) { php_http_curl_request_t *curl = h->ctx; php_http_curl_request_storage_t *storage = get_storage(curl->handle); @@ -304,30 +305,28 @@ static STATUS php_http_curl_request_prepare(php_http_request_t *h, php_http_requ curl_easy_setopt(curl->handle, CURLOPT_URL, storage->url); /* request method */ - switch (meth) { - case PHP_HTTP_GET: + switch (php_http_select_str(meth, 4, "GET", "HEAD", "POST", "PUT")) { + case 0: curl_easy_setopt(curl->handle, CURLOPT_HTTPGET, 1L); break; - case PHP_HTTP_HEAD: + case 1: curl_easy_setopt(curl->handle, CURLOPT_NOBODY, 1L); break; - case PHP_HTTP_POST: + case 2: curl_easy_setopt(curl->handle, CURLOPT_POST, 1L); break; - case PHP_HTTP_PUT: + case 3: curl_easy_setopt(curl->handle, CURLOPT_UPLOAD, 1L); break; default: { - const char *name = php_http_request_method_name(meth); - - if (name) { - curl_easy_setopt(curl->handle, CURLOPT_CUSTOMREQUEST, name); + if (meth) { + curl_easy_setopt(curl->handle, CURLOPT_CUSTOMREQUEST, meth); } else { - php_http_error(HE_WARNING, PHP_HTTP_E_REQUEST_METHOD, "Unsupported request method: %d (%s)", meth, url); + php_http_error(HE_WARNING, PHP_HTTP_E_REQUEST_METHOD, "Unsupported request method: '%s' (%s)", meth, url); return FAILURE; } break; @@ -342,17 +341,12 @@ static STATUS php_http_curl_request_prepare(php_http_request_t *h, php_http_requ * same semantics as those specified in section 9« reveal that not any single defined HTTP/1.1 method * does not allow a request body. */ - switch (meth) { - default: { - size_t body_size = php_http_message_body_size(body); - - curl_easy_setopt(curl->handle, CURLOPT_IOCTLDATA, body); - curl_easy_setopt(curl->handle, CURLOPT_READDATA, body); - curl_easy_setopt(curl->handle, CURLOPT_INFILESIZE, body_size); - curl_easy_setopt(curl->handle, CURLOPT_POSTFIELDSIZE, body_size); - break; - } - } + size_t body_size = php_http_message_body_size(body); + + curl_easy_setopt(curl->handle, CURLOPT_IOCTLDATA, body); + curl_easy_setopt(curl->handle, CURLOPT_READDATA, body); + curl_easy_setopt(curl->handle, CURLOPT_INFILESIZE, body_size); + curl_easy_setopt(curl->handle, CURLOPT_POSTFIELDSIZE, body_size); } return SUCCESS; @@ -394,7 +388,7 @@ static void php_http_curl_request_pool_responsehandler(php_http_request_pool_t * } -#ifdef PHP_HTTP_HAVE_EVENT +#if PHP_HTTP_HAVE_EVENT typedef struct php_http_request_pool_event { struct event evnt; @@ -483,7 +477,7 @@ static int php_http_curl_request_pool_socket_callback(CURL *easy, curl_socket_t ev = ecalloc(1, sizeof(php_http_request_pool_event_t)); ev->pool = pool; curl_multi_assign(curl->handle, sock, ev); - event_base_set(PHP_HTTP_G->request_pool.event_base, &ev->evnt); + event_base_set(PHP_HTTP_G->curl.event_base, &ev->evnt); } else { event_del(&ev->evnt); } @@ -501,6 +495,7 @@ static int php_http_curl_request_pool_socket_callback(CURL *easy, curl_socket_t case CURL_POLL_REMOVE: efree(ev); + /* no break */ case CURL_POLL_NONE: return 0; @@ -534,7 +529,7 @@ static void php_http_curl_request_pool_timer_callback(CURLM *multi, long timeout if (!event_initialized(curl->timeout)) { event_set(curl->timeout, -1, 0, php_http_curl_request_pool_timeout_callback, pool); - event_base_set(PHP_HTTP_G->request_pool.event_base, curl->timeout); + event_base_set(PHP_HTTP_G->curl.event_base, curl->timeout); } else if (event_pending(curl->timeout, EV_TIMEOUT, NULL)) { event_del(curl->timeout); } @@ -591,6 +586,7 @@ static STATUS set_options(php_http_request_t *h, HashTable *options) int range_req = 0; php_http_curl_request_t *curl = h->ctx; CURL *ch = curl->handle; + TSRMLS_FETCH_FROM_CTX(h->ts); /* proxy */ if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("proxyhost"), IS_STRING))) { @@ -629,6 +625,30 @@ static STATUS set_options(php_http_request_t *h, HashTable *options) if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("ipresolve"), IS_LONG)) && Z_LVAL_P(zoption)) { curl_easy_setopt(ch, CURLOPT_IPRESOLVE, Z_LVAL_P(zoption)); } +#if PHP_HTTP_CURL_VERSION(7,21,3) + if (curl->options.resolve) { + curl_slist_free_all(curl->options.resolve); + curl->options.resolve = NULL; + } + if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("resolve"), IS_ARRAY))) { + php_http_array_hashkey_t key = php_http_array_hashkey_init(0); + HashPosition pos; + zval **data; + + FOREACH_KEYVAL(pos, zoption, key, data) { + zval *cpy = php_http_ztyp(IS_STRING, *data); + + curl->options.resolve = curl_slist_append(curl->options.resolve, Z_STRVAL_P(cpy)); + + zval_ptr_dtor(&cpy); + } + } +#endif +#if PHP_HTTP_CURL_VERSION(7,24,0) + if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("dns_servers"), IS_STRING)) && Z_STRLEN_P(zoption)) { + curl_easy_setopt(ch, CURLOPT_DNS_SERVERS, Z_STRVAL_P(zoption)); + } +#endif /* limits */ if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("low_speed_limit"), IS_LONG))) { @@ -861,7 +881,7 @@ static STATUS set_options(php_http_request_t *h, HashTable *options) 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); } @@ -1065,7 +1085,6 @@ static STATUS get_info(CURL *ch, HashTable *info) add_assoc_zval_ex(&array, "ssl_engines", sizeof("ssl_engines"), subarray); curl_slist_free_all(s); } -#if PHP_HTTP_CURL_VERSION(7,14,1) if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_COOKIELIST, &s)) { MAKE_STD_ZVAL(subarray); array_init(subarray); @@ -1077,12 +1096,9 @@ static STATUS get_info(CURL *ch, HashTable *info) add_assoc_zval_ex(&array, "cookies", sizeof("cookies"), subarray); curl_slist_free_all(s); } -#endif -#if PHP_HTTP_CURL_VERSION(7,18,2) if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_REDIRECT_URL, &c)) { add_assoc_string_ex(&array, "redirect_url", sizeof("redirect_url"), c ? c : "", 1); } -#endif #if PHP_HTTP_CURL_VERSION(7,19,0) if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_PRIMARY_IP, &c)) { add_assoc_string_ex(&array, "primary_ip", sizeof("primary_ip"), c ? c : "", 1); @@ -1098,7 +1114,24 @@ static STATUS get_info(CURL *ch, HashTable *info) add_assoc_long_ex(&array, "condition_unmet", sizeof("condition_unmet"), l); } #endif +#if PHP_HTTP_CURL_VERSION(7,21,0) + if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_PRIMARY_PORT, &l)) { + add_assoc_long_ex(&array, "primary_port", sizeof("primary_port"), l); + } +#endif +#if PHP_HTTP_CURL_VERSION(7,21,0) + if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_LOCAL_IP, &c)) { + add_assoc_string_ex(&array, "local_ip", sizeof("local_ip"), c ? c : "", 1); + } +#endif +#if PHP_HTTP_CURL_VERSION(7,21,0) + if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_LOCAL_PORT, &l)) { + add_assoc_long_ex(&array, "local_port", sizeof("local_port"), l); + } +#endif + /* END::CURLINFO */ + #if PHP_HTTP_CURL_VERSION(7,19,1) && defined(PHP_HTTP_HAVE_OPENSSL) { int i; @@ -1138,76 +1171,20 @@ static STATUS get_info(CURL *ch, HashTable *info) } -#ifdef ZTS -static void *php_http_curl_request_datashare_locks_init(void) -{ - int i; - php_http_curl_request_datashare_lock_t *locks = pecalloc(CURL_LOCK_DATA_LAST, sizeof(*locks), 1); - - if (locks) { - for (i = 0; i < CURL_LOCK_DATA_LAST; ++i) { - locks[i].mx = tsrm_mutex_alloc(); - } - } - - return locks; -} - -static void php_http_curl_request_datashare_locks_dtor(void *l) -{ - int i; - php_http_curl_request_datashare_lock_t *locks = l; - - for (i = 0; i < CURL_LOCK_DATA_LAST; ++i) { - tsrm_mutex_free(locks[i].mx); - } - pefree(locks, 1); -} - -static void php_http_curl_request_datashare_lock_func(CURL *handle, curl_lock_data data, curl_lock_access locktype, void *userptr) -{ - php_http_curl_request_datashare_lock_t *locks = userptr; - - /* TSRM can't distinguish shared/exclusive locks */ - tsrm_mutex_lock(locks[data].mx); - locks[data].ch = handle; -} - -static void php_http_curl_request_datashare_unlock_func(CURL *handle, curl_lock_data data, void *userptr) -{ - php_http_curl_request_datashare_lock_t *locks = userptr; - - if (locks[data].ch == handle) { - tsrm_mutex_unlock(locks[data].mx); - } -} -#endif - - - /* request datashare handler ops */ -static php_http_request_datashare_t *php_http_curl_request_datashare_init(php_http_request_datashare_t *h, void *handle TSRMLS_DC) +static php_http_request_datashare_t *php_http_curl_request_datashare_init(php_http_request_datashare_t *h, void *handle) { php_http_curl_request_datashare_t *curl; + TSRMLS_FETCH_FROM_CTX(h->ts); if (!handle && !(handle = php_http_resource_factory_handle_ctor(h->rf TSRMLS_CC))) { php_http_error(HE_WARNING, PHP_HTTP_E_REQUEST_DATASHARE, "could not initialize curl share handle"); return NULL; } - curl = pecalloc(1, sizeof(*curl), h->persistent); + curl = ecalloc(1, sizeof(*curl)); curl->handle = handle; -#ifdef ZTS - if (h->persistent) { - curl->locks = php_http_request_datashare_locks_init(); - if (curl->locks) { - curl_share_setopt(share->ch, CURLSHOPT_LOCKFUNC, php_http_curl_request_datashare_lock_func); - curl_share_setopt(share->ch, CURLSHOPT_UNLOCKFUNC, php_http_curl_request_datashare_unlock_func); - curl_share_setopt(share->ch, CURLSHOPT_USERDATA, curl->locks); - } - } -#endif h->ctx = curl; return h; @@ -1220,13 +1197,7 @@ static void php_http_curl_request_datashare_dtor(php_http_request_datashare_t *h php_http_resource_factory_handle_dtor(h->rf, curl->handle TSRMLS_CC); -#ifdef ZTS - if (h->persistent) { - http_request_datashare_locks_dtor(curl->locks); - } -#endif - - pefree(curl, h->persistent); + efree(curl); h->ctx = NULL; } @@ -1274,7 +1245,7 @@ static STATUS php_http_curl_request_datashare_setopt(php_http_request_datashare_ break; case PHP_HTTP_REQUEST_DATASHARE_OPT_RESOLVER: - if (CURLSHE_OK != (rc = curl_share_setopt(curl->handle, *((zend_bool *) arg) ? CURLSHOPT_SHARE : CURLSHOPT_UNSHARE, CURL_LOCK_DATA_COOKIE))) { + if (CURLSHE_OK != (rc = curl_share_setopt(curl->handle, *((zend_bool *) arg) ? CURLSHOPT_SHARE : CURLSHOPT_UNSHARE, CURL_LOCK_DATA_DNS))) { TSRMLS_FETCH_FROM_CTX(h->ts); php_http_error(HE_WARNING, PHP_HTTP_E_REQUEST_DATASHARE, "Could not %s sharing of resolver data: %s", *((zend_bool *) arg) ? "enable" : "disable", curl_share_strerror(rc)); @@ -1282,6 +1253,17 @@ static STATUS php_http_curl_request_datashare_setopt(php_http_request_datashare_ } break; +#if PHP_HTTP_CURL_VERSION(7,23,0) + case PHP_HTTP_REQUEST_DATASHARE_OPT_SSLSESSIONS: + if (CURLSHE_OK != (rc = curl_share_setopt(curl->handle, *((zend_bool *) arg) ? CURLSHOPT_SHARE : CURLSHOPT_UNSHARE, CURL_LOCK_DATA_SSL_SESSION))) { + TSRMLS_FETCH_FROM_CTX(h->ts); + + php_http_error(HE_WARNING, PHP_HTTP_E_REQUEST_DATASHARE, "Could not %s sharing of SSL session data: %s", *((zend_bool *) arg) ? "enable" : "disable", curl_share_strerror(rc)); + return FAILURE; + } + break; +#endif + default: return FAILURE; } @@ -1314,9 +1296,10 @@ PHP_HTTP_API php_http_request_datashare_ops_t *php_http_curl_get_request_datasha /* request pool handler ops */ -static php_http_request_pool_t *php_http_curl_request_pool_init(php_http_request_pool_t *h, void *handle TSRMLS_DC) +static php_http_request_pool_t *php_http_curl_request_pool_init(php_http_request_pool_t *h, void *handle) { php_http_curl_request_pool_t *curl; + TSRMLS_FETCH_FROM_CTX(h->ts); if (!handle && !(handle = php_http_resource_factory_handle_ctor(h->rf TSRMLS_CC))) { php_http_error(HE_WARNING, PHP_HTTP_E_REQUEST_POOL, "could not initialize curl pool handle"); @@ -1336,7 +1319,7 @@ static void php_http_curl_request_pool_dtor(php_http_request_pool_t *h) php_http_curl_request_pool_t *curl = h->ctx; TSRMLS_FETCH_FROM_CTX(h->ts); -#ifdef PHP_HTTP_HAVE_EVENT +#if PHP_HTTP_HAVE_EVENT if (curl->timeout) { efree(curl->timeout); curl->timeout = NULL; @@ -1345,17 +1328,18 @@ static void php_http_curl_request_pool_dtor(php_http_request_pool_t *h) curl->unfinished = 0; php_http_request_pool_reset(h); - php_http_resource_factory_handle_dtor(h->rf, curl->handle); + php_http_resource_factory_handle_dtor(h->rf, curl->handle TSRMLS_CC); efree(curl); h->ctx = NULL; } -static STATUS php_http_curl_request_pool_attach(php_http_request_pool_t *h, php_http_request_t *r, php_http_request_method_t m, const char *url, php_http_message_body_t *body) +static STATUS php_http_curl_request_pool_attach(php_http_request_pool_t *h, php_http_request_t *r, const char *m, const char *url, php_http_message_body_t *body) { php_http_curl_request_pool_t *curl = h->ctx; php_http_curl_request_t *recurl = r->ctx; CURLMcode rs; + TSRMLS_FETCH_FROM_CTX(h->ts); if (SUCCESS != php_http_curl_request_prepare(r, m, url, body)) { return FAILURE; @@ -1375,6 +1359,7 @@ static STATUS php_http_curl_request_pool_detach(php_http_request_pool_t *h, php_ php_http_curl_request_pool_t *curl = h->ctx; php_http_curl_request_t *recurl = r->ctx; CURLMcode rs = curl_multi_remove_handle(curl->handle, recurl->handle); + TSRMLS_FETCH_FROM_CTX(h->ts); if (CURLM_OK == rs) { return SUCCESS; @@ -1397,9 +1382,9 @@ static STATUS php_http_curl_request_pool_wait(php_http_request_pool_t *h, struct struct timeval timeout; php_http_curl_request_pool_t *curl = h->ctx; -#ifdef PHP_HTTP_HAVE_EVENT +#if PHP_HTTP_HAVE_EVENT if (curl->useevents) { - TSRMLS_FETCH_FROM_CTX(pool->ts); + TSRMLS_FETCH_FROM_CTX(h->ts); php_http_error(HE_WARNING, PHP_HTTP_E_RUNTIME, "not implemented"); return FAILURE; @@ -1438,10 +1423,10 @@ static STATUS php_http_curl_request_pool_wait(php_http_request_pool_t *h, struct static int php_http_curl_request_pool_once(php_http_request_pool_t *h) { php_http_curl_request_pool_t *curl = h->ctx; - TSRMLS_FETCH_FROM_CTX(h->ts); -#ifdef PHP_HTTP_HAVE_EVENT +#if PHP_HTTP_HAVE_EVENT if (curl->useevents) { + TSRMLS_FETCH_FROM_CTX(h->ts); php_http_error(HE_WARNING, PHP_HTTP_E_RUNTIME, "not implemented"); return FAILURE; } @@ -1454,14 +1439,16 @@ static int php_http_curl_request_pool_once(php_http_request_pool_t *h) return curl->unfinished; } -#ifdef PHP_HTTP_HAVE_EVENT +#if PHP_HTTP_HAVE_EVENT static void dolog(int i, const char *m) { fprintf(stderr, "%d: %s\n", i, m); } #endif static STATUS php_http_curl_request_pool_exec(php_http_request_pool_t *h) { -#ifdef PHP_HTTP_HAVE_EVENT + TSRMLS_FETCH_FROM_CTX(h->ts); + +#if PHP_HTTP_HAVE_EVENT php_http_curl_request_pool_t *curl = h->ctx; if (curl->useevents) { @@ -1470,7 +1457,7 @@ static STATUS php_http_curl_request_pool_exec(php_http_request_pool_t *h) #if DBG_EVENTS fprintf(stderr, "X"); #endif - event_base_dispatch(PHP_HTTP_G->request_pool.event_base); + event_base_dispatch(PHP_HTTP_G->curl.event_base); } while (curl->unfinished); } else #endif @@ -1589,7 +1576,7 @@ static php_http_request_t *php_http_curl_request_init(php_http_request_t *h, voi curl_easy_setopt(handle, CURLOPT_DEBUGDATA, h); curl_easy_setopt(handle, CURLOPT_PROGRESSDATA, h); - php_http_curl_request_reset(h TSRMLS_CC); + php_http_curl_request_reset(h); return h; } @@ -1614,6 +1601,7 @@ static php_http_request_t *php_http_curl_request_copy(php_http_request_t *from, static void php_http_curl_request_dtor(php_http_request_t *h) { php_http_curl_request_t *ctx = h->ctx; + TSRMLS_FETCH_FROM_CTX(h->ts); curl_easy_setopt(ctx->handle, CURLOPT_NOPROGRESS, 1L); curl_easy_setopt(ctx->handle, CURLOPT_PROGRESSFUNCTION, NULL); @@ -1629,7 +1617,7 @@ static void php_http_curl_request_dtor(php_http_request_t *h) curl_slist_free_all(ctx->options.headers); ctx->options.headers = NULL; } - php_http_request_progress_dtor(&ctx->progress); + php_http_request_progress_dtor(&ctx->progress TSRMLS_CC); efree(ctx); h->ctx = NULL; @@ -1667,6 +1655,12 @@ static STATUS php_http_curl_request_reset(php_http_request_t *h) curl_easy_setopt(ch, CURLOPT_HTTPPROXYTUNNEL, 0L); curl_easy_setopt(ch, CURLOPT_DNS_CACHE_TIMEOUT, 60L); curl_easy_setopt(ch, CURLOPT_IPRESOLVE, 0); +#if PHP_HTTP_CURL_VERSION(7,21,3) + curl_easy_setopt(ch, CURLOPT_RESOLVE, NULL); +#endif +#if PHP_HTTP_CURL_VERSION(7,24,0) + curl_easy_setopt(ch, CURLOPT_DNS_SERVERS, NULL); +#endif curl_easy_setopt(ch, CURLOPT_LOW_SPEED_LIMIT, 0L); curl_easy_setopt(ch, CURLOPT_LOW_SPEED_TIME, 0L); /* LFS weirdance @@ -1761,7 +1755,7 @@ static STATUS php_http_curl_request_reset(php_http_request_t *h) return SUCCESS; } -static STATUS php_http_curl_request_exec(php_http_request_t *h, php_http_request_method_t meth, const char *url, php_http_message_body_t *body) +static STATUS php_http_curl_request_exec(php_http_request_t *h, const char *meth, const char *url, php_http_message_body_t *body) { uint tries = 0; CURLcode result; @@ -1814,6 +1808,7 @@ retry: static STATUS php_http_curl_request_setopt(php_http_request_t *h, php_http_request_setopt_opt_t opt, void *arg) { php_http_curl_request_t *curl = h->ctx; + TSRMLS_FETCH_FROM_CTX(h->ts); switch (opt) { case PHP_HTTP_REQUEST_OPT_SETTINGS: @@ -2130,11 +2125,23 @@ PHP_MSHUTDOWN_FUNCTION(http_curl) PHP_RINIT_FUNCTION(http_curl) { -#ifdef PHP_HTTP_HAVE_EVENT - if (!PHP_HTTP_G->request_pool.event_base && !(PHP_HTTP_G->request_pool.event_base = event_init())) { +#if PHP_HTTP_HAVE_EVENT + if (!PHP_HTTP_G->curl.event_base && !(PHP_HTTP_G->curl.event_base = event_init())) { return FAILURE; } #endif return SUCCESS; } + +#endif /* PHP_HTTP_HAVE_CURL */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ +