27 #ifndef _bes_http_CURL_UTILS_H_
28 #define _bes_http_CURL_UTILS_H_ 1
33 #include <curl/curl.h>
34 #include <curl/easy.h>
38 #include "EffectiveUrl.h"
42 void http_get_and_write_resource(
const std::string &url,
44 std::vector<std::string> *http_response_headers);
46 void http_get(
const std::string &url,
char *response_buf);
48 std::string http_get_as_string(
const std::string &url);
54 std::string get_netrc_filename();
56 std::string get_cookie_filename();
58 bool is_retryable(std::string url);
60 unsigned long max_redirects();
62 std::string hyrax_user_agent();
64 CURL *init(
const std::string &target_url,
65 const struct curl_slist *http_request_headers,
66 std::vector<std::string> *resp_hdrs);
69 const std::string &target_url,
70 const struct curl_slist *http_request_headers,
71 std::vector<std::string> *http_response_hdrs);
73 bool configure_curl_handle_for_proxy(CURL *ceh,
const std::string &url);
75 void set_error_buffer(CURL *ceh,
char *error_buffer);
77 void unset_error_buffer(CURL *ceh);
79 void eval_curl_easy_setopt_result(CURLcode result,
82 char *ebuf, std::string file,
85 bool eval_curl_easy_perform_code(CURL *ceh,
89 unsigned int attempt);
91 bool eval_http_get_response(CURL *ceh,
char *error_buffer,
const std::string &requested_url);
93 void super_easy_perform(CURL *ceh);
95 std::string get_effective_url(CURL *ceh, std::string requested_url);
97 std::string get_range_arg_string(
const unsigned long long &offset,
const unsigned long long &size);
99 std::string http_status_to_string(
int status);
101 std::string error_message(CURLcode response_code,
char *error_buf);
103 size_t c_write_data(
void *buffer,
size_t size,
size_t nmemb,
void *data);
105 void read_data(CURL *c_handle);
107 curl_slist *append_http_header(curl_slist *slist,
const std::string &header_name,
const std::string &value);
109 curl_slist *add_auth_headers(curl_slist *request_headers);
GenericDocument< UTF8<> > Document
GenericDocument with UTF8 encoding.