X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_request_api.c;h=63eb9831c59c8ac058339d73a87f8b536b08fc64;hp=d2a8445e47211f3edad819aadce0045357bafc02;hb=a52c5612eddc62880c3ff4b8b43f991f8d1e2523;hpb=b08947e98f1832091c8a9f6dea3799e0524d2822 diff --git a/http_request_api.c b/http_request_api.c index d2a8445..63eb983 100644 --- a/http_request_api.c +++ b/http_request_api.c @@ -20,6 +20,8 @@ #endif #include "php.h" +#ifdef HTTP_HAVE_CURL + #include "php_http.h" #include "php_http_std_defs.h" #include "php_http_api.h" @@ -39,10 +41,6 @@ ZEND_EXTERN_MODULE_GLOBALS(http); -#ifndef HTTP_CURL_USE_ZEND_MM -# define HTTP_CURL_USE_ZEND_MM 0 -#endif - #if LIBCURL_VERSION_NUM < 0x070c00 # define curl_easy_strerror(code) HTTP_G(request).error #endif @@ -119,35 +117,6 @@ static int http_curl_dummy_callback(char *data, size_t n, size_t l, void *s) { r static http_curl_callback_ctx *_http_curl_callback_data(void *data TSRMLS_DC); -#if HTTP_CURL_USE_ZEND_MM -static void http_curl_free(void *p) { efree(p); } -static char *http_curl_strdup(const char *p) { return estrdup(p); } -static void *http_curl_malloc(size_t s) { return emalloc(s); } -static void *http_curl_realloc(void *p, size_t s) { return erealloc(p, s); } -static void *http_curl_calloc(size_t n, size_t s) { return ecalloc(n, s); } -#endif - -/* {{{ STATUS http_request_global_init() */ -STATUS _http_request_global_init(void) -{ -#if HTTP_CURL_USE_ZEND_MM - if (CURLE_OK != curl_global_init_mem(CURL_GLOBAL_ALL, - http_curl_malloc, - http_curl_free, - http_curl_realloc, - http_curl_strdup, - http_curl_calloc)) { - return FAILURE; - } -#else - if (CURLE_OK != curl_global_init(CURL_GLOBAL_ALL)) { - return FAILURE; - } -#endif - return SUCCESS; -} -/* }}} */ - /* {{{ void *http_request_data_copy(int, void *) */ void *_http_request_data_copy(int type, void *data TSRMLS_DC) { @@ -239,7 +208,7 @@ PHP_HTTP_API STATUS _http_request_body_fill(http_request_body *body, HashTable * err = curl_formadd(&http_post_data[0], &http_post_data[1], CURLFORM_COPYNAME, key, CURLFORM_COPYCONTENTS, Z_STRVAL_PP(data), - CURLFORM_CONTENTSLENGTH, Z_STRLEN_PP(data), + CURLFORM_CONTENTSLENGTH, (long) Z_STRLEN_PP(data), CURLFORM_END ); if (CURLE_OK != err) { @@ -495,7 +464,7 @@ PHP_HTTP_API STATUS _http_request_init(CURL *ch, http_request_method meth, char phpstr_fix(qstr); HTTP_CURL_OPT(COOKIE, http_request_data_copy(COPY_STRING, qstr->data)); } - phpstr_free(qstr); + phpstr_free(&qstr); } else { HTTP_CURL_OPT(COOKIE, NULL); } @@ -523,7 +492,7 @@ PHP_HTTP_API STATUS _http_request_init(CURL *ch, http_request_method meth, char } /* resume */ - if (zoption = http_curl_getopt(options, "resume", IS_LONG)) { + if ((zoption = http_curl_getopt(options, "resume", IS_LONG)) && (Z_LVAL_P(zoption) != 0)) { range_req = 1; HTTP_CURL_OPT(RESUME_FROM, Z_LVAL_P(zoption)); } else { @@ -545,11 +514,11 @@ PHP_HTTP_API STATUS _http_request_init(CURL *ch, http_request_method meth, char HTTP_CURL_OPT(TIMEVALUE, 0); } - /* timeout, defaults to 3 */ + /* timeout, defaults to 0 */ if (zoption = http_curl_getopt(options, "timeout", IS_LONG)) { HTTP_CURL_OPT(TIMEOUT, Z_LVAL_P(zoption)); } else { - HTTP_CURL_OPT(TIMEOUT, 3); + HTTP_CURL_OPT(TIMEOUT, 0); } /* connecttimeout, defaults to 3 */ @@ -1005,6 +974,8 @@ static inline zval *_http_curl_getopt_ex(HashTable *options, char *key, size_t k } /* }}} */ +#endif + /* * Local variables: * tab-width: 4