Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::HTTPLibClient Class Reference
Inheritance diagram for duckdb::HTTPLibClient:
Collaboration diagram for duckdb::HTTPLibClient:

Public Member Functions

 HTTPLibClient (HTTPParams &http_params, const string &proto_host_port)
void Initialize (HTTPParams &http_params) override
unique_ptr< HTTPResponse > Get (GetRequestInfo &info) override
unique_ptr< HTTPResponse > Put (PutRequestInfo &info) override
unique_ptr< HTTPResponse > Head (HeadRequestInfo &info) override
unique_ptr< HTTPResponse > Delete (DeleteRequestInfo &info) override
unique_ptr< HTTPResponse > Post (PostRequestInfo &info) override
Public Member Functions inherited from duckdb::HTTPClient
 HTTPClient (const string &proto_host_port)
virtual void Cleanup ()
unique_ptr< HTTPResponse > Request (BaseRequest &request)
const string & GetBaseUrl () const

Public Attributes

unique_ptr< duckdb_httplib::Client > client

Private Member Functions

duckdb_httplib::Headers TransformHeaders (const HTTPHeaders &header_map, const HTTPParams &params)
unique_ptr< HTTPResponse > TransformResponse (const duckdb_httplib::Response &response)
unique_ptr< HTTPResponse > TransformResult (const duckdb_httplib::Result &res)

Constructor & Destructor Documentation

◆ HTTPLibClient()

duckdb::HTTPLibClient::HTTPLibClient ( HTTPParams & http_params,
const string & proto_host_port )
inline
293738 : HTTPClient(proto_host_port) {
293739 client = make_uniq<duckdb_httplib::Client>(proto_host_port);
293740 Initialize(http_params);
293741 }

Member Function Documentation

◆ Initialize()

void duckdb::HTTPLibClient::Initialize ( HTTPParams & http_params)
inlineoverridevirtual

Implements duckdb::HTTPClient.

293742 {
293743 auto sec = static_cast<time_t>(http_params.timeout);
293744 auto usec = static_cast<time_t>(http_params.timeout_usec);
293745 client->set_follow_location(http_params.follow_location);
293746 client->set_keep_alive(http_params.keep_alive);
293747 client->set_write_timeout(sec, usec);
293748 client->set_read_timeout(sec, usec);
293749 client->set_connection_timeout(sec, usec);
293750 client->set_decompress(false);
293751
293752 if (!http_params.http_proxy.empty()) {
293753 client->set_proxy(http_params.http_proxy, static_cast<int>(http_params.http_proxy_port));
293754
293755 if (!http_params.http_proxy_username.empty()) {
293756 client->set_proxy_basic_auth(http_params.http_proxy_username, http_params.http_proxy_password);
293757 }
293758 }
293759 }

◆ Get()

unique_ptr< HTTPResponse > duckdb::HTTPLibClient::Get ( GetRequestInfo & info)
inlineoverridevirtual

Implements duckdb::HTTPClient.

293760 {
293761 auto headers = TransformHeaders(info.headers, info.params);
293762 if (!info.response_handler && !info.content_handler) {
293763 return TransformResult(client->Get(info.path, headers));
293764 } else {
293765 return TransformResult(client->Get(
293766 info.path, headers,
293767 [&](const duckdb_httplib::Response &response) {
293768 auto http_response = TransformResponse(response);
293769 return info.response_handler(*http_response);
293770 },
293771 [&](const char *data, size_t data_length) {
293772 return info.content_handler(const_data_ptr_cast(data), data_length);
293773 }));
293774 }
293775 }

◆ Put()

unique_ptr< HTTPResponse > duckdb::HTTPLibClient::Put ( PutRequestInfo & info)
inlineoverridevirtual

Implements duckdb::HTTPClient.

293776 {
293777 throw NotImplementedException("PUT request not implemented");
293778 }

◆ Head()

unique_ptr< HTTPResponse > duckdb::HTTPLibClient::Head ( HeadRequestInfo & info)
inlineoverridevirtual

Implements duckdb::HTTPClient.

293780 {
293781 throw NotImplementedException("HEAD request not implemented");
293782 }

◆ Delete()

unique_ptr< HTTPResponse > duckdb::HTTPLibClient::Delete ( DeleteRequestInfo & info)
inlineoverridevirtual

Implements duckdb::HTTPClient.

293784 {
293785 throw NotImplementedException("DELETE request not implemented");
293786 }

◆ Post()

unique_ptr< HTTPResponse > duckdb::HTTPLibClient::Post ( PostRequestInfo & info)
inlineoverridevirtual

Implements duckdb::HTTPClient.

293788 {
293789 throw NotImplementedException("POST request not implemented");
293790 }

◆ TransformHeaders()

duckdb_httplib::Headers duckdb::HTTPLibClient::TransformHeaders ( const HTTPHeaders & header_map,
const HTTPParams & params )
inlineprivate
293795 {
293796 duckdb_httplib::Headers headers;
293797 for (auto &entry : header_map) {
293798 headers.insert(entry);
293799 }
293800 return headers;
293801 }

◆ TransformResponse()

unique_ptr< HTTPResponse > duckdb::HTTPLibClient::TransformResponse ( const duckdb_httplib::Response & response)
inlineprivate
293803 {
293804 auto status_code = HTTPUtil::ToStatusCode(response.status);
293805 auto result = make_uniq<HTTPResponse>(status_code);
293806 result->body = response.body;
293807 result->reason = response.reason;
293808 for (auto &entry : response.headers) {
293809 result->headers.Insert(entry.first, entry.second);
293810 }
293811 return result;
293812 }

◆ TransformResult()

unique_ptr< HTTPResponse > duckdb::HTTPLibClient::TransformResult ( const duckdb_httplib::Result & res)
inlineprivate
293814 {
293815 if (res.error() == duckdb_httplib::Error::Success) {
293816 auto &response = res.value();
293817 return TransformResponse(response);
293818 } else {
293819 auto result = make_uniq<HTTPResponse>(HTTPStatusCode::INVALID);
293820 result->request_error = to_string(res.error());
293821 return result;
293822 }
293823 }
std::string to_string(const T &value)
Definition duckdb.cpp:19425

The documentation for this class was generated from the following file: