X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_curl.c;h=5e588283570d87fd64e53df8c5abf5e130ac422a;hp=ae8eb556872f5dd5b71452954550ac5ab69773de;hb=29a54250b58e444974ae19840194e214cab80bd5;hpb=a07b79b1871054ca17e48b69445b4dc201f24662 diff --git a/php_http_curl.c b/php_http_curl.c index ae8eb55..5e58828 100644 --- a/php_http_curl.c +++ b/php_http_curl.c @@ -1,17 +1,27 @@ - -#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 { @@ -47,7 +57,7 @@ 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; @@ -395,7 +405,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; @@ -484,7 +494,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); } @@ -535,7 +545,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); } @@ -863,7 +873,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); } @@ -1340,7 +1350,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; @@ -1403,7 +1413,7 @@ 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(h->ts); @@ -1444,10 +1454,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; } @@ -1460,7 +1470,7 @@ 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); } @@ -1469,7 +1479,7 @@ static STATUS php_http_curl_request_pool_exec(php_http_request_pool_t *h) { TSRMLS_FETCH_FROM_CTX(h->ts); -#ifdef PHP_HTTP_HAVE_EVENT +#if PHP_HTTP_HAVE_EVENT php_http_curl_request_pool_t *curl = h->ctx; if (curl->useevents) { @@ -1478,7 +1488,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 @@ -2140,11 +2150,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 + */ +