X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Fhttp.cc;h=465ce6186708c9d3c5eeb78fb0703343e4d7e056;hb=b6719ab469b16022edd830cb90bc476b17fa6743;hp=02d20cee2664ca627a3d2c75013fed511d209f22;hpb=a0a194ba0789e0650329d81a5ed12620360789eb;p=awesomized%2Flibmemcached diff --git a/libtest/http.cc b/libtest/http.cc index 02d20cee..465ce618 100644 --- a/libtest/http.cc +++ b/libtest/http.cc @@ -34,11 +34,11 @@ * */ -#include +#include "libtest/yatlcon.h" #include -#if defined(HAVE_CURL_CURL_H) && HAVE_CURL_CURL_H +#if defined(HAVE_LIBCURL) && HAVE_LIBCURL #include #else class CURL; @@ -47,23 +47,23 @@ class CURL; static void cleanup_curl(void) { -#if defined(HAVE_CURL_CURL_H) && HAVE_CURL_CURL_H +#if defined(HAVE_LIBCURL) && HAVE_LIBCURL curl_global_cleanup(); #endif } static void initialize_curl_startup() { -#if defined(HAVE_CURL_CURL_H) && HAVE_CURL_CURL_H +#if defined(HAVE_LIBCURL) && HAVE_LIBCURL if (curl_global_init(CURL_GLOBAL_ALL)) { - fatal_message("curl_global_init(CURL_GLOBAL_ALL) failed"); + FATAL("curl_global_init(CURL_GLOBAL_ALL) failed"); } #endif if (atexit(cleanup_curl)) { - fatal_message("atexit() failed"); + FATAL("atexit() failed"); } } @@ -73,7 +73,7 @@ static void initialize_curl(void) int ret; if ((ret= pthread_once(&start_key_once, initialize_curl_startup)) != 0) { - fatal_message(strerror(ret)); + FATAL(strerror(ret)); } } @@ -87,7 +87,7 @@ static size_t http_get_result_callback(void *ptr, size_t size, size_t nmemb, voi vchar_t *_body= (vchar_t*)data; _body->resize(size * nmemb); - memcpy(&_body[0], ptr, _body->size()); + memcpy(&(*_body)[0], ptr, _body->size()); return _body->size(); } @@ -97,14 +97,14 @@ static void init(CURL *curl, const std::string& url) (void)http_get_result_callback; (void)curl; (void)url; +#if defined(HAVE_LIBCURL) && HAVE_LIBCURL if (HAVE_LIBCURL) { -#if defined(HAVE_LIBCURL) && HAVE_LIBCURL assert(curl); curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); curl_easy_setopt(curl, CURLOPT_USERAGENT, YATL_USERAGENT); -#endif } +#endif } HTTP::HTTP(const std::string& url_arg) : @@ -118,9 +118,9 @@ bool GET::execute() { (void)init; +#if defined(HAVE_LIBCURL) && HAVE_LIBCURL if (HAVE_LIBCURL) { -#if defined(HAVE_LIBCURL) && HAVE_LIBCURL CURL *curl= curl_easy_init(); init(curl, url()); @@ -134,17 +134,17 @@ bool GET::execute() curl_easy_cleanup(curl); return bool(retref == CURLE_OK); -#endif } +#endif return false; } bool POST::execute() { +#if defined(HAVE_LIBCURL) && HAVE_LIBCURL if (HAVE_LIBCURL) { -#if defined(HAVE_LIBCURL) && HAVE_LIBCURL CURL *curl= curl_easy_init();; init(curl, url()); @@ -158,17 +158,17 @@ bool POST::execute() curl_easy_cleanup(curl); return bool(retref == CURLE_OK); -#endif } +#endif return false; } bool TRACE::execute() { +#if defined(HAVE_LIBCURL) && HAVE_LIBCURL if (HAVE_LIBCURL) { -#if defined(HAVE_LIBCURL) && HAVE_LIBCURL CURL *curl= curl_easy_init();; init(curl, url()); @@ -183,18 +183,18 @@ bool TRACE::execute() curl_easy_cleanup(curl); return retref == CURLE_OK; -#endif } +#endif return false; } bool HEAD::execute() { +#if defined(HAVE_LIBCURL) && HAVE_LIBCURL if (HAVE_LIBCURL) { -#if defined(HAVE_LIBCURL) && HAVE_LIBCURL - CURL *curl= curl_easy_init();; + CURL *curl= curl_easy_init(); init(curl, url()); @@ -207,8 +207,8 @@ bool HEAD::execute() curl_easy_cleanup(curl); return retref == CURLE_OK; -#endif } +#endif return false; }