@@ -82,35 +82,35 @@ SIMPLE_HTTP_TINY_LONG(HttpStatusCode)
82
82
#undef SIMPLE_HTTP_TINY_LONG
83
83
84
84
using CurlSetupCallback = std::function<void (CURL *curl)>;
85
- inline CurlSetupCallback NoopCurlSetupCallback = [](auto ){};
85
+ inline static CurlSetupCallback NoopCurlSetupCallback = [](auto ){};
86
86
87
87
using CurlHeaderCallback = std::function<curl_slist*(curl_slist *chunk)>;
88
- inline CurlHeaderCallback NoopCurlHeaderCallback = [](curl_slist *chunk){ return chunk; };
88
+ inline static CurlHeaderCallback NoopCurlHeaderCallback = [](curl_slist *chunk){ return chunk; };
89
89
90
90
using ErrorCallback = std::function<void (const std::string&)>;
91
- inline ErrorCallback NoopErrorCallback = [](auto &){};
91
+ inline static ErrorCallback NoopErrorCallback = [](auto &){};
92
92
93
93
using Headers = std::unordered_map<std::string, std::string>;
94
94
using PathSegments = std::vector<PathSegment>;
95
95
using QueryParameters = std::vector<std::pair<QueryParameterKey, QueryParameterValue>>;
96
96
97
97
inline static const std::string WHITESPACE = " \n\t\f\v\r " ;
98
98
99
- static std::string leftTrim (const std::string &candidate) {
99
+ inline static std::string leftTrim (const std::string &candidate) {
100
100
size_t start = candidate.find_first_not_of (WHITESPACE);
101
101
return (start == std::string::npos) ? " " : candidate.substr (start);
102
102
}
103
103
104
- static std::string rightTrim (const std::string &candidate) {
104
+ inline static std::string rightTrim (const std::string &candidate) {
105
105
size_t end = candidate.find_last_not_of (WHITESPACE);
106
106
return (end == std::string::npos) ? " " : candidate.substr (0 , end + 1 );
107
107
}
108
108
109
- static std::string trim (const std::string &candidate) {
109
+ inline static std::string trim (const std::string &candidate) {
110
110
return rightTrim (leftTrim (candidate));
111
111
}
112
112
113
- static std::vector<std::string> vec (const std::string& candidate, const char separator) {
113
+ inline static std::vector<std::string> vec (const std::string& candidate, const char separator) {
114
114
std::vector<std::string> container;
115
115
std::stringstream ss (candidate);
116
116
std::string temp;
@@ -120,7 +120,7 @@ static std::vector<std::string> vec(const std::string& candidate, const char sep
120
120
return container;
121
121
}
122
122
123
- struct HttpResponseHeaders {
123
+ struct HttpResponseHeaders final {
124
124
explicit HttpResponseHeaders (Headers headers) : headers_(std::move(headers)) {}
125
125
explicit HttpResponseHeaders (const std::string &header_string) : headers_(parse(header_string)) {}
126
126
@@ -148,13 +148,13 @@ struct HttpResponseHeaders {
148
148
}
149
149
};
150
150
151
- struct HttpResponse {
151
+ struct HttpResponse final {
152
152
HttpStatusCode status;
153
153
HttpResponseHeaders headers;
154
154
HttpResponseBody body;
155
155
};
156
156
157
- struct HttpUrl {
157
+ struct HttpUrl final {
158
158
HttpUrl () = default ;
159
159
160
160
HttpUrl (Protcol protocol,
@@ -265,74 +265,74 @@ Predicate<A> between_inclusive(const A &a, const A &b) {
265
265
}
266
266
267
267
// Information Responses
268
- inline HttpStatusCode CONTINUE = HttpStatusCode{100 };
269
- inline HttpStatusCode SWITCHING_PROTOCOL = HttpStatusCode{101 };
270
- inline HttpStatusCode PROCESSING = HttpStatusCode{102 };
271
- inline HttpStatusCode EARLY_HINTS = HttpStatusCode{103 };
268
+ inline static HttpStatusCode CONTINUE = HttpStatusCode{100 };
269
+ inline static HttpStatusCode SWITCHING_PROTOCOL = HttpStatusCode{101 };
270
+ inline static HttpStatusCode PROCESSING = HttpStatusCode{102 };
271
+ inline static HttpStatusCode EARLY_HINTS = HttpStatusCode{103 };
272
272
273
273
// Successful Responses
274
- inline HttpStatusCode OK = HttpStatusCode{200 };
275
- inline HttpStatusCode CREATED = HttpStatusCode{201 };
276
- inline HttpStatusCode ACCEPTED = HttpStatusCode{202 };
277
- inline HttpStatusCode NON_AUTHORITATIVE_INFORMATION = HttpStatusCode{203 };
278
- inline HttpStatusCode NO_CONTENT = HttpStatusCode{204 };
279
- inline HttpStatusCode RESET_CONTENT = HttpStatusCode{205 };
280
- inline HttpStatusCode PARTIAL_CONTENT = HttpStatusCode{206 };
281
- inline HttpStatusCode MULTI_STATUS = HttpStatusCode{207 };
282
- inline HttpStatusCode ALREADY_REPORTED = HttpStatusCode{208 };
283
- inline HttpStatusCode IM_USED = HttpStatusCode{226 };
274
+ inline static HttpStatusCode OK = HttpStatusCode{200 };
275
+ inline static HttpStatusCode CREATED = HttpStatusCode{201 };
276
+ inline static HttpStatusCode ACCEPTED = HttpStatusCode{202 };
277
+ inline static HttpStatusCode NON_AUTHORITATIVE_INFORMATION = HttpStatusCode{203 };
278
+ inline static HttpStatusCode NO_CONTENT = HttpStatusCode{204 };
279
+ inline static HttpStatusCode RESET_CONTENT = HttpStatusCode{205 };
280
+ inline static HttpStatusCode PARTIAL_CONTENT = HttpStatusCode{206 };
281
+ inline static HttpStatusCode MULTI_STATUS = HttpStatusCode{207 };
282
+ inline static HttpStatusCode ALREADY_REPORTED = HttpStatusCode{208 };
283
+ inline static HttpStatusCode IM_USED = HttpStatusCode{226 };
284
284
285
285
// Redirection Messages
286
- inline HttpStatusCode MULTIPLE_CHOICE = HttpStatusCode{300 };
287
- inline HttpStatusCode MOVED_PERMANENTLY = HttpStatusCode{301 };
288
- inline HttpStatusCode FOUND = HttpStatusCode{302 };
289
- inline HttpStatusCode SEE_OTHER = HttpStatusCode{303 };
290
- inline HttpStatusCode NOT_MODIFIED = HttpStatusCode{304 };
291
- inline HttpStatusCode USE_PROXY = HttpStatusCode{305 };
292
- inline HttpStatusCode TEMPORARY_REDIRECT = HttpStatusCode{307 };
293
- inline HttpStatusCode PERMANENT_REDIRECT = HttpStatusCode{308 };
286
+ inline static HttpStatusCode MULTIPLE_CHOICE = HttpStatusCode{300 };
287
+ inline static HttpStatusCode MOVED_PERMANENTLY = HttpStatusCode{301 };
288
+ inline static HttpStatusCode FOUND = HttpStatusCode{302 };
289
+ inline static HttpStatusCode SEE_OTHER = HttpStatusCode{303 };
290
+ inline static HttpStatusCode NOT_MODIFIED = HttpStatusCode{304 };
291
+ inline static HttpStatusCode USE_PROXY = HttpStatusCode{305 };
292
+ inline static HttpStatusCode TEMPORARY_REDIRECT = HttpStatusCode{307 };
293
+ inline static HttpStatusCode PERMANENT_REDIRECT = HttpStatusCode{308 };
294
294
295
295
// Client Error Responses
296
- inline HttpStatusCode BAD_REQUEST = HttpStatusCode{400 };
297
- inline HttpStatusCode UNAUTHORIZED = HttpStatusCode{401 };
298
- inline HttpStatusCode PAYMENT_REQUIRED = HttpStatusCode{402 };
299
- inline HttpStatusCode FORBIDDEN = HttpStatusCode{403 };
300
- inline HttpStatusCode NOT_FOUND = HttpStatusCode{404 };
301
- inline HttpStatusCode METHOD_NOT_ALLOWED = HttpStatusCode{405 };
302
- inline HttpStatusCode NOT_ACCEPTABLE = HttpStatusCode{406 };
303
- inline HttpStatusCode PROXY_AUTHENTICATION_REQUIRED = HttpStatusCode{407 };
304
- inline HttpStatusCode REQUEST_TIMEOUT = HttpStatusCode{408 };
305
- inline HttpStatusCode CONFLICT = HttpStatusCode{409 };
306
- inline HttpStatusCode GONE = HttpStatusCode{410 };
307
- inline HttpStatusCode LENGTH_REQUIRED = HttpStatusCode{411 };
308
- inline HttpStatusCode PRECONDITION_FAILED = HttpStatusCode{412 };
309
- inline HttpStatusCode PAYLOAD_TOO_LARGE = HttpStatusCode{413 };
310
- inline HttpStatusCode URI_TOO_LONG = HttpStatusCode{414 };
311
- inline HttpStatusCode UNSUPPORTED_MEDIA_TYPE = HttpStatusCode{415 };
312
- inline HttpStatusCode RANGE_NOT_SATISFIABLE = HttpStatusCode{416 };
313
- inline HttpStatusCode EXPECTATION_FAILED = HttpStatusCode{417 };
314
- inline HttpStatusCode IM_A_TEAPOT = HttpStatusCode{418 };
315
- inline HttpStatusCode UNPROCESSABLE_ENTITY = HttpStatusCode{422 };
316
- inline HttpStatusCode FAILED_DEPENDENCY = HttpStatusCode{424 };
317
- inline HttpStatusCode TOO_EARLY = HttpStatusCode{425 };
318
- inline HttpStatusCode UPGRADE_REQUIRED = HttpStatusCode{426 };
319
- inline HttpStatusCode PRECONDITION_REQUIRED = HttpStatusCode{428 };
320
- inline HttpStatusCode TOO_MANY_REQUESTS = HttpStatusCode{429 };
321
- inline HttpStatusCode REQUEST_HEADER_FIELDS_TOO_LARGE = HttpStatusCode{431 };
322
- inline HttpStatusCode UNAVAILABLE_FOR_LEGAL_REASONS = HttpStatusCode{451 };
296
+ inline static HttpStatusCode BAD_REQUEST = HttpStatusCode{400 };
297
+ inline static HttpStatusCode UNAUTHORIZED = HttpStatusCode{401 };
298
+ inline static HttpStatusCode PAYMENT_REQUIRED = HttpStatusCode{402 };
299
+ inline static HttpStatusCode FORBIDDEN = HttpStatusCode{403 };
300
+ inline static HttpStatusCode NOT_FOUND = HttpStatusCode{404 };
301
+ inline static HttpStatusCode METHOD_NOT_ALLOWED = HttpStatusCode{405 };
302
+ inline static HttpStatusCode NOT_ACCEPTABLE = HttpStatusCode{406 };
303
+ inline static HttpStatusCode PROXY_AUTHENTICATION_REQUIRED = HttpStatusCode{407 };
304
+ inline static HttpStatusCode REQUEST_TIMEOUT = HttpStatusCode{408 };
305
+ inline static HttpStatusCode CONFLICT = HttpStatusCode{409 };
306
+ inline static HttpStatusCode GONE = HttpStatusCode{410 };
307
+ inline static HttpStatusCode LENGTH_REQUIRED = HttpStatusCode{411 };
308
+ inline static HttpStatusCode PRECONDITION_FAILED = HttpStatusCode{412 };
309
+ inline static HttpStatusCode PAYLOAD_TOO_LARGE = HttpStatusCode{413 };
310
+ inline static HttpStatusCode URI_TOO_LONG = HttpStatusCode{414 };
311
+ inline static HttpStatusCode UNSUPPORTED_MEDIA_TYPE = HttpStatusCode{415 };
312
+ inline static HttpStatusCode RANGE_NOT_SATISFIABLE = HttpStatusCode{416 };
313
+ inline static HttpStatusCode EXPECTATION_FAILED = HttpStatusCode{417 };
314
+ inline static HttpStatusCode IM_A_TEAPOT = HttpStatusCode{418 };
315
+ inline static HttpStatusCode UNPROCESSABLE_ENTITY = HttpStatusCode{422 };
316
+ inline static HttpStatusCode FAILED_DEPENDENCY = HttpStatusCode{424 };
317
+ inline static HttpStatusCode TOO_EARLY = HttpStatusCode{425 };
318
+ inline static HttpStatusCode UPGRADE_REQUIRED = HttpStatusCode{426 };
319
+ inline static HttpStatusCode PRECONDITION_REQUIRED = HttpStatusCode{428 };
320
+ inline static HttpStatusCode TOO_MANY_REQUESTS = HttpStatusCode{429 };
321
+ inline static HttpStatusCode REQUEST_HEADER_FIELDS_TOO_LARGE = HttpStatusCode{431 };
322
+ inline static HttpStatusCode UNAVAILABLE_FOR_LEGAL_REASONS = HttpStatusCode{451 };
323
323
324
324
// Server Error Responses
325
- inline HttpStatusCode INTERNAL_SERVER_ERROR = HttpStatusCode{500 };
326
- inline HttpStatusCode NOT_IMPLEMENTED = HttpStatusCode{501 };
327
- inline HttpStatusCode BAD_GATEWAY = HttpStatusCode{502 };
328
- inline HttpStatusCode SERVICE_UNAVAILABLE = HttpStatusCode{503 };
329
- inline HttpStatusCode GATEWAY_TIMEOUT = HttpStatusCode{504 };
330
- inline HttpStatusCode HTTP_VERSION_NOT_SUPPORTED = HttpStatusCode{505 };
331
- inline HttpStatusCode VARIANT_ALSO_NEGOTIATES = HttpStatusCode{506 };
332
- inline HttpStatusCode INSUFFICIENT_STORAGE = HttpStatusCode{507 };
333
- inline HttpStatusCode LOOP_DETECTED = HttpStatusCode{508 };
334
- inline HttpStatusCode NOT_EXTENDED = HttpStatusCode{510 };
335
- inline HttpStatusCode NETWORK_AUTHENTICATION_REQUIRED = HttpStatusCode{511 };
325
+ inline static HttpStatusCode INTERNAL_SERVER_ERROR = HttpStatusCode{500 };
326
+ inline static HttpStatusCode NOT_IMPLEMENTED = HttpStatusCode{501 };
327
+ inline static HttpStatusCode BAD_GATEWAY = HttpStatusCode{502 };
328
+ inline static HttpStatusCode SERVICE_UNAVAILABLE = HttpStatusCode{503 };
329
+ inline static HttpStatusCode GATEWAY_TIMEOUT = HttpStatusCode{504 };
330
+ inline static HttpStatusCode HTTP_VERSION_NOT_SUPPORTED = HttpStatusCode{505 };
331
+ inline static HttpStatusCode VARIANT_ALSO_NEGOTIATES = HttpStatusCode{506 };
332
+ inline static HttpStatusCode INSUFFICIENT_STORAGE = HttpStatusCode{507 };
333
+ inline static HttpStatusCode LOOP_DETECTED = HttpStatusCode{508 };
334
+ inline static HttpStatusCode NOT_EXTENDED = HttpStatusCode{510 };
335
+ inline static HttpStatusCode NETWORK_AUTHENTICATION_REQUIRED = HttpStatusCode{511 };
336
336
337
337
inline static Predicate<HttpStatusCode> informational () {
338
338
return between_inclusive (CONTINUE, EARLY_HINTS);
@@ -354,7 +354,7 @@ inline static Predicate<HttpStatusCode> server_error() {
354
354
return between_inclusive (INTERNAL_SERVER_ERROR, NETWORK_AUTHENTICATION_REQUIRED);
355
355
}
356
356
357
- struct Client {
357
+ struct Client final {
358
358
Client () : error_callback_(NoopErrorCallback), debug_(false ), verify_(true ) {}
359
359
explicit Client (ErrorCallback error_callback) : error_callback_(std::move(error_callback)), debug_(false ), verify_(true ) {}
360
360
0 commit comments