Skip to content

Commit 513414c

Browse files
committed
Cleanup
1 parent 065ff77 commit 513414c

File tree

1 file changed

+71
-71
lines changed

1 file changed

+71
-71
lines changed

simple_http.hpp

+71-71
Original file line numberDiff line numberDiff line change
@@ -82,35 +82,35 @@ SIMPLE_HTTP_TINY_LONG(HttpStatusCode)
8282
#undef SIMPLE_HTTP_TINY_LONG
8383

8484
using CurlSetupCallback = std::function<void(CURL *curl)>;
85-
inline CurlSetupCallback NoopCurlSetupCallback = [](auto){};
85+
inline static CurlSetupCallback NoopCurlSetupCallback = [](auto){};
8686

8787
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; };
8989

9090
using ErrorCallback = std::function<void(const std::string&)>;
91-
inline ErrorCallback NoopErrorCallback = [](auto&){};
91+
inline static ErrorCallback NoopErrorCallback = [](auto&){};
9292

9393
using Headers = std::unordered_map<std::string, std::string>;
9494
using PathSegments = std::vector<PathSegment>;
9595
using QueryParameters = std::vector<std::pair<QueryParameterKey, QueryParameterValue>>;
9696

9797
inline static const std::string WHITESPACE = "\n\t\f\v\r ";
9898

99-
static std::string leftTrim(const std::string &candidate) {
99+
inline static std::string leftTrim(const std::string &candidate) {
100100
size_t start = candidate.find_first_not_of(WHITESPACE);
101101
return (start == std::string::npos) ? "" : candidate.substr(start);
102102
}
103103

104-
static std::string rightTrim(const std::string &candidate) {
104+
inline static std::string rightTrim(const std::string &candidate) {
105105
size_t end = candidate.find_last_not_of(WHITESPACE);
106106
return (end == std::string::npos) ? "" : candidate.substr(0, end + 1);
107107
}
108108

109-
static std::string trim(const std::string &candidate) {
109+
inline static std::string trim(const std::string &candidate) {
110110
return rightTrim(leftTrim(candidate));
111111
}
112112

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) {
114114
std::vector<std::string> container;
115115
std::stringstream ss(candidate);
116116
std::string temp;
@@ -120,7 +120,7 @@ static std::vector<std::string> vec(const std::string& candidate, const char sep
120120
return container;
121121
}
122122

123-
struct HttpResponseHeaders {
123+
struct HttpResponseHeaders final {
124124
explicit HttpResponseHeaders(Headers headers) : headers_(std::move(headers)) {}
125125
explicit HttpResponseHeaders(const std::string &header_string) : headers_(parse(header_string)) {}
126126

@@ -148,13 +148,13 @@ struct HttpResponseHeaders {
148148
}
149149
};
150150

151-
struct HttpResponse {
151+
struct HttpResponse final {
152152
HttpStatusCode status;
153153
HttpResponseHeaders headers;
154154
HttpResponseBody body;
155155
};
156156

157-
struct HttpUrl {
157+
struct HttpUrl final {
158158
HttpUrl() = default;
159159

160160
HttpUrl(Protcol protocol,
@@ -265,74 +265,74 @@ Predicate<A> between_inclusive(const A &a, const A &b) {
265265
}
266266

267267
// 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};
272272

273273
// 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};
284284

285285
// 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};
294294

295295
// 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};
323323

324324
// 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};
336336

337337
inline static Predicate<HttpStatusCode> informational() {
338338
return between_inclusive(CONTINUE, EARLY_HINTS);
@@ -354,7 +354,7 @@ inline static Predicate<HttpStatusCode> server_error() {
354354
return between_inclusive(INTERNAL_SERVER_ERROR, NETWORK_AUTHENTICATION_REQUIRED);
355355
}
356356

357-
struct Client {
357+
struct Client final {
358358
Client() : error_callback_(NoopErrorCallback), debug_(false), verify_(true) {}
359359
explicit Client(ErrorCallback error_callback) : error_callback_(std::move(error_callback)), debug_(false), verify_(true) {}
360360

0 commit comments

Comments
 (0)