+
83 _stream_cancelled =
false;
+
84 _curl_buffer_headers.clear();
+
85 _curl_buffer_body.clear();
+
+
87 CURLcode code{CURLE_OK};
+
+
+
90 case http_method::GET:
+
+
92 add_parameters_to_uri(uri, parameters);
+
+
94 curl_easy_setopt(_connection, CURLOPT_HTTPGET, 1L);
+
+
+
+
98 case http_method::POST:
+
+
100 if (parameters.empty())
+
+
+
103 curl_easy_setopt(_connection, CURLOPT_POST, 1L);
+
+
-
-
108 curl_easy_setopt(_connection, CURLOPT_POST, 1L);
-
-
-
-
112 curl_mime *mime{parameters_to_curl_mime(uri, parameters)};
-
-
114 curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);
-
-
-
-
-
119 case http_method::PATCH:
-
-
121 if (!parameters.empty())
-
-
123 curl_mime *mime{parameters_to_curl_mime(uri, parameters)};
-
-
125 curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);
-
-
-
-
129 code = curl_easy_setopt(_connection, CURLOPT_CUSTOMREQUEST,
"PATCH");
-
130 if (code != CURLE_OK)
-
-
132 throw CURLException{code,
"Failed to set URI", _curl_buffer_error};
-
-
-
-
-
137 case http_method::PUT:
-
-
139 if (!parameters.empty())
-
-
141 curl_mime *mime{parameters_to_curl_mime(uri, parameters)};
-
-
143 curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);
-
-
-
-
147 code = curl_easy_setopt(_connection, CURLOPT_CUSTOMREQUEST,
"PUT");
-
148 if (code != CURLE_OK)
-
-
150 throw CURLException{code,
"Failed to set URI", _curl_buffer_error};
-
-
-
-
-
155 case http_method::DELETE:
-
-
157 if (!parameters.empty())
-
-
159 curl_mime *mime{parameters_to_curl_mime(uri, parameters)};
-
-
161 curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);
-
-
-
-
165 code = curl_easy_setopt(_connection, CURLOPT_CUSTOMREQUEST,
"DELETE");
-
166 if (code != CURLE_OK)
-
-
168 throw CURLException{code,
"Failed to set URI", _curl_buffer_error};
-
+
107 curl_mime *mime{parameters_to_curl_mime(uri, parameters)};
+
+
109 curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);
+
+
+
+
+
114 case http_method::PATCH:
+
+
116 if (!parameters.empty())
+
+
118 curl_mime *mime{parameters_to_curl_mime(uri, parameters)};
+
+
120 curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);
+
+
+
+
124 code = curl_easy_setopt(_connection, CURLOPT_CUSTOMREQUEST,
"PATCH");
+
125 if (code != CURLE_OK)
+
+
127 throw CURLException{code,
"Failed to set URI", _curl_buffer_error};
+
+
+
+
+
132 case http_method::PUT:
+
+
134 if (!parameters.empty())
+
+
136 curl_mime *mime{parameters_to_curl_mime(uri, parameters)};
+
+
138 curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);
+
+
+
+
142 code = curl_easy_setopt(_connection, CURLOPT_CUSTOMREQUEST,
"PUT");
+
143 if (code != CURLE_OK)
+
+
145 throw CURLException{code,
"Failed to set URI", _curl_buffer_error};
+
+
+
+
+
150 case http_method::DELETE:
+
+
152 if (!parameters.empty())
+
+
154 curl_mime *mime{parameters_to_curl_mime(uri, parameters)};
+
+
156 curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);
+
+
+
+
160 code = curl_easy_setopt(_connection, CURLOPT_CUSTOMREQUEST,
"DELETE");
+
161 if (code != CURLE_OK)
+
+
163 throw CURLException{code,
"Failed to set URI", _curl_buffer_error};
+
+
+
+
+
+
169 debuglog <<
"Making request to: " << uri <<
'\n';
-
-
-
-
174 debuglog <<
"Making request to: " << uri <<
'\n';
-
-
-
177 code = curl_easy_setopt(_connection, CURLOPT_URL, uri.data());
-
178 if (code != CURLE_OK)
-
-
180 throw CURLException{code,
"Failed to set URI", _curl_buffer_error};
-
-
-
-
184 code = curl_easy_perform(_connection);
-
-
186 || (code == CURLE_ABORTED_BY_CALLBACK && _stream_cancelled))
-
-
-
-
190 curl_easy_getinfo(_connection, CURLINFO_RESPONSE_CODE, &http_status);
-
191 answer.http_status =
static_cast<uint16_t
>(http_status);
-
192 debuglog <<
"HTTP status code: " << http_status <<
'\n';
-
-
194 answer.headers = _curl_buffer_headers;
-
195 answer.body = _curl_buffer_body;
-
-
-
-
199 answer.curl_error_code =
static_cast<uint8_t
>(code);
-
200 answer.error_message = _curl_buffer_error;
-
201 debuglog <<
"libcurl error: " << code <<
'\n';
-
202 debuglog << _curl_buffer_error <<
'\n';
-
-
-
-
+
+
172 code = curl_easy_setopt(_connection, CURLOPT_URL, uri.data());
+
173 if (code != CURLE_OK)
+
+
175 throw CURLException{code,
"Failed to set URI", _curl_buffer_error};
+
+
+
+
179 code = curl_easy_perform(_connection);
+
+
181 || (code == CURLE_ABORTED_BY_CALLBACK && _stream_cancelled))
+
+
+
+
185 curl_easy_getinfo(_connection, CURLINFO_RESPONSE_CODE, &http_status);
+
186 answer.http_status =
static_cast<uint16_t
>(http_status);
+
187 debuglog <<
"HTTP status code: " << http_status <<
'\n';
+
+
189 answer.headers = _curl_buffer_headers;
+
190 answer.body = _curl_buffer_body;
+
+
+
+
194 answer.curl_error_code =
static_cast<uint8_t
>(code);
+
195 answer.error_message = _curl_buffer_error;
+
196 debuglog <<
"libcurl error: " << code <<
'\n';
+
197 debuglog << _curl_buffer_error <<
'\n';
+
+
+
+