Add headers to answer_type.
This commit is contained in:
parent
96e9d9a9fd
commit
9c279822b2
|
@ -96,7 +96,8 @@ public:
|
|||
private:
|
||||
CURL *_connection;
|
||||
char _curl_buffer_error[CURL_ERROR_SIZE];
|
||||
string _curl_buffer;
|
||||
string _curl_buffer_headers;
|
||||
string _curl_buffer_body;
|
||||
|
||||
/*!
|
||||
* @brief libcurl write callback function.
|
||||
|
|
|
@ -48,18 +48,28 @@ struct answer_type
|
|||
* @since 0.1.0
|
||||
*/
|
||||
uint8_t curl_error_code;
|
||||
|
||||
/*!
|
||||
* @brief The error message.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
string error_message;
|
||||
|
||||
/*!
|
||||
* @brief HTTP status code.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
uint16_t http_status;
|
||||
|
||||
/*!
|
||||
* @brief The headers of the response from the server.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
string headers;
|
||||
|
||||
/*!
|
||||
* @brief The response from the server, usually JSON.
|
||||
*
|
||||
|
|
|
@ -113,7 +113,16 @@ void CURLWrapper::setup_curl()
|
|||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
||||
code = curl_easy_setopt(_connection, CURLOPT_WRITEDATA, &_curl_buffer);
|
||||
code = curl_easy_setopt(_connection, CURLOPT_HEADERDATA,
|
||||
&_curl_buffer_headers);
|
||||
if (code != CURLE_OK)
|
||||
{
|
||||
throw CURLException{code, "Failed to set header data",
|
||||
_curl_buffer_error};
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
||||
code = curl_easy_setopt(_connection, CURLOPT_WRITEDATA, &_curl_buffer_body);
|
||||
if (code != CURLE_OK)
|
||||
{
|
||||
throw CURLException{code, "Failed to set write data",
|
||||
|
|
Loading…
Reference in New Issue
Block a user