27#ifndef _bes_http_CURL_UTILS_H_
28#define _bes_http_CURL_UTILS_H_ 1
39#include "EffectiveUrl.h"
47void http_get_and_write_resource(
const std::shared_ptr<http::url>& target_url,
49 std::vector<std::string> *http_response_headers);
51void http_get(
const std::string &url,
char *response_buf);
53std::string http_get_as_string(
const std::string &url);
55rapidjson::Document http_get_as_json(
const std::string &target_url);
57std::shared_ptr<http::EffectiveUrl> retrieve_effective_url(
const std::shared_ptr<http::url> &starting_point_url);
59std::string get_netrc_filename();
61std::string get_cookie_filename();
63bool is_retryable(std::string url);
65unsigned long max_redirects();
67std::string hyrax_user_agent();
69CURL *init(
const std::string &target_url,
70 const struct curl_slist *http_request_headers,
71 std::vector<std::string> *resp_hdrs);
74 const std::string &target_url,
75 const struct curl_slist *http_request_headers,
76 std::vector<std::string> *http_response_hdrs);
78bool configure_curl_handle_for_proxy(CURL *ceh,
const std::string &url);
80void set_error_buffer(CURL *ceh,
char *error_buffer);
82void unset_error_buffer(CURL *ceh);
84void eval_curl_easy_setopt_result(CURLcode result,
87 char *ebuf, std::string file,
90bool eval_curl_easy_perform_code(CURL *ceh,
94 unsigned int attempt);
96bool eval_http_get_response(CURL *ceh,
char *error_buffer,
const std::string &requested_url);
98void super_easy_perform(CURL *ceh,
const int fd);
99void super_easy_perform(CURL *ceh);
101std::string get_effective_url(CURL *ceh, std::string requested_url);
103std::string get_range_arg_string(
const unsigned long long &offset,
const unsigned long long &size);
105std::string http_status_to_string(
int status);
107std::string error_message(CURLcode response_code,
char *error_buf);
109size_t c_write_data(
void *buffer,
size_t size,
size_t nmemb,
void *data);
111void read_data(CURL *c_handle);
113curl_slist *append_http_header(curl_slist *slist,
const std::string &header_name,
const std::string &value);
115curl_slist *add_edl_auth_headers(curl_slist *request_headers);