X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_curl_api.c;h=9bf3857ac1c704008d951c579a665d543f2dea25;hp=24524ced68d42af020016b7df7d27b8fad825b27;hb=ac1377e599c5333de70745bea2cc14e2d75b1921;hpb=e26d1af5bcad6068bcd4854693d6a1fa12d7912d diff --git a/http_curl_api.c b/http_curl_api.c index 24524ce..9bf3857 100644 --- a/http_curl_api.c +++ b/http_curl_api.c @@ -33,6 +33,7 @@ #include "php_http.h" #include "php_http_api.h" #include "php_http_curl_api.h" +#include "php_http_std_defs.h" #include "ext/standard/php_smart_str.h" @@ -48,7 +49,7 @@ ZEND_DECLARE_MODULE_GLOBALS(http) } \ http_curl_initbuf(); \ http_curl_setopts(ch, URL, options); - + #define http_curl_cleanup(ch, clean_curl) \ http_curl_freestr(); \ @@ -98,7 +99,7 @@ ZEND_DECLARE_MODULE_GLOBALS(http) HTTP_G(curlbuf).free += bsize; \ } \ } - + #define http_curl_copystr(s) _http_curl_copystr((s) TSRMLS_CC) static inline char *_http_curl_copystr(const char *str TSRMLS_DC); @@ -253,8 +254,6 @@ static inline void _http_curl_setopts(CURL *ch, const char *url, HashTable *opti if (Z_LVAL_P(zoption)) { curl_easy_setopt(ch, CURLOPT_ENCODING, ""); } - } else { - curl_easy_setopt(ch, CURLOPT_ENCODING, ""); } /* another port */ @@ -506,7 +505,7 @@ PHP_HTTP_API STATUS _http_get_ex(CURL *ch, const char *URL, HashTable *options, HashTable *info, char **data, size_t *data_len TSRMLS_DC) { zend_bool clean_curl = 0; - + http_curl_startup(ch, clean_curl, URL, options); curl_easy_setopt(ch, CURLOPT_NOBODY, 0); curl_easy_setopt(ch, CURLOPT_POST, 0); @@ -516,14 +515,14 @@ PHP_HTTP_API STATUS _http_get_ex(CURL *ch, const char *URL, HashTable *options, php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not perform request"); return FAILURE; } - + if (info) { http_curl_getinfo(ch, info); } - + http_curl_copybuf(data, data_len); http_curl_cleanup(ch, clean_curl); - + return SUCCESS; } @@ -532,7 +531,7 @@ PHP_HTTP_API STATUS _http_head_ex(CURL *ch, const char *URL, HashTable *options, HashTable *info, char **data, size_t *data_len TSRMLS_DC) { zend_bool clean_curl = 0; - + http_curl_startup(ch, clean_curl, URL, options); curl_easy_setopt(ch, CURLOPT_NOBODY, 1); curl_easy_setopt(ch, CURLOPT_POST, 0); @@ -542,14 +541,14 @@ PHP_HTTP_API STATUS _http_head_ex(CURL *ch, const char *URL, HashTable *options, php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not perform request"); return FAILURE; } - + if (info) { http_curl_getinfo(ch, info); } - + http_curl_copybuf(data, data_len); http_curl_cleanup(ch, clean_curl); - + return SUCCESS; } @@ -559,7 +558,7 @@ PHP_HTTP_API STATUS _http_post_data_ex(CURL *ch, const char *URL, char *postdata size_t *data_len TSRMLS_DC) { zend_bool clean_curl = 0; - + http_curl_startup(ch, clean_curl, URL, options); curl_easy_setopt(ch, CURLOPT_POST, 1); curl_easy_setopt(ch, CURLOPT_POSTFIELDS, postdata); @@ -570,14 +569,14 @@ PHP_HTTP_API STATUS _http_post_data_ex(CURL *ch, const char *URL, char *postdata php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not perform request"); return FAILURE; } - + if (info) { http_curl_getinfo(ch, info); } - + http_curl_copybuf(data, data_len); http_curl_cleanup(ch, clean_curl); - + return SUCCESS; } /* }}} */ @@ -616,7 +615,7 @@ PHP_HTTP_API STATUS _http_post_curldata_ex(CURL *ch, const char *URL, char **data, size_t *data_len TSRMLS_DC) { zend_bool clean_curl = 0; - + http_curl_startup(ch, clean_curl, URL, options); curl_easy_setopt(ch, CURLOPT_POST, 1); curl_easy_setopt(ch, CURLOPT_HTTPPOST, curldata); @@ -626,14 +625,14 @@ PHP_HTTP_API STATUS _http_post_curldata_ex(CURL *ch, const char *URL, php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not perform request"); return FAILURE; } - + if (info) { http_curl_getinfo(ch, info); } - + http_curl_copybuf(data, data_len); http_curl_cleanup(ch, clean_curl); - + return SUCCESS; } /* }}} */