52
52
#define CPPHTTPLIB_THREAD_POOL_COUNT 8
53
53
#endif
54
54
55
+ /*
56
+ * Headers
57
+ */
58
+
55
59
#ifdef _WIN32
56
60
#ifndef _CRT_SECURE_NO_WARNINGS
57
61
#define _CRT_SECURE_NO_WARNINGS
61
65
#define _CRT_NONSTDC_NO_DEPRECATE
62
66
#endif // _CRT_NONSTDC_NO_DEPRECATE
63
67
64
- /*
65
- * Headers
66
- */
67
-
68
68
#if defined(_MSC_VER)
69
69
#ifdef _WIN64
70
70
typedef __int64 ssize_t ;
@@ -589,37 +589,45 @@ class Client {
589
589
std::shared_ptr<Response> Head (const char *path, const Headers &headers);
590
590
591
591
std::shared_ptr<Response> Post (const char *path, const std::string &body,
592
- const char *content_type, bool compress = false );
592
+ const char *content_type,
593
+ bool compress = false );
593
594
594
595
std::shared_ptr<Response> Post (const char *path, const Headers &headers,
595
596
const std::string &body,
596
597
const char *content_type,
597
598
bool compress = false );
598
599
599
- std::shared_ptr<Response> Post (const char *path, const Params ¶ms, bool compress = false );
600
+ std::shared_ptr<Response> Post (const char *path, const Params ¶ms,
601
+ bool compress = false );
600
602
601
603
std::shared_ptr<Response> Post (const char *path, const Headers &headers,
602
604
const Params ¶ms, bool compress = false );
603
605
604
606
std::shared_ptr<Response> Post (const char *path,
605
- const MultipartFormDataItems &items, bool compress = false );
607
+ const MultipartFormDataItems &items,
608
+ bool compress = false );
606
609
607
610
std::shared_ptr<Response> Post (const char *path, const Headers &headers,
608
- const MultipartFormDataItems &items, bool compress = false );
611
+ const MultipartFormDataItems &items,
612
+ bool compress = false );
609
613
610
614
std::shared_ptr<Response> Put (const char *path, const std::string &body,
611
- const char *content_type, bool compress = false );
615
+ const char *content_type,
616
+ bool compress = false );
612
617
613
618
std::shared_ptr<Response> Put (const char *path, const Headers &headers,
614
619
const std::string &body,
615
- const char *content_type, bool compress = false );
620
+ const char *content_type,
621
+ bool compress = false );
616
622
617
623
std::shared_ptr<Response> Patch (const char *path, const std::string &body,
618
- const char *content_type, bool compress = false );
624
+ const char *content_type,
625
+ bool compress = false );
619
626
620
627
std::shared_ptr<Response> Patch (const char *path, const Headers &headers,
621
628
const std::string &body,
622
- const char *content_type, bool compress = false );
629
+ const char *content_type,
630
+ bool compress = false );
623
631
624
632
std::shared_ptr<Response> Delete (const char *path);
625
633
@@ -3120,14 +3128,14 @@ inline std::shared_ptr<Response> Client::Head(const char *path,
3120
3128
3121
3129
inline std::shared_ptr<Response> Client::Post (const char *path,
3122
3130
const std::string &body,
3123
- const char *content_type, bool compress) {
3131
+ const char *content_type,
3132
+ bool compress) {
3124
3133
return Post (path, Headers (), body, content_type, compress);
3125
3134
}
3126
3135
3127
- inline std::shared_ptr<Response> Client::Post (const char *path,
3128
- const Headers &headers,
3129
- const std::string &body,
3130
- const char *content_type, bool compress) {
3136
+ inline std::shared_ptr<Response>
3137
+ Client::Post (const char *path, const Headers &headers, const std::string &body,
3138
+ const char *content_type, bool compress) {
3131
3139
Request req;
3132
3140
req.method = " POST" ;
3133
3141
req.headers = headers;
@@ -3137,9 +3145,7 @@ inline std::shared_ptr<Response> Client::Post(const char *path,
3137
3145
req.body = body;
3138
3146
3139
3147
if (compress) {
3140
- if (!detail::compress (req.body )) {
3141
- return nullptr ;
3142
- }
3148
+ if (!detail::compress (req.body )) { return nullptr ; }
3143
3149
req.headers .emplace (" Content-Encoding" , " gzip" );
3144
3150
}
3145
3151
@@ -3148,13 +3154,15 @@ inline std::shared_ptr<Response> Client::Post(const char *path,
3148
3154
return send (req, *res) ? res : nullptr ;
3149
3155
}
3150
3156
3151
- inline std::shared_ptr<Response> Client::Post ( const char *path,
3152
- const Params ¶ms, bool compress) {
3157
+ inline std::shared_ptr<Response>
3158
+ Client::Post ( const char *path, const Params ¶ms, bool compress) {
3153
3159
return Post (path, Headers (), params, compress);
3154
3160
}
3155
3161
3156
- inline std::shared_ptr<Response>
3157
- Client::Post (const char *path, const Headers &headers, const Params ¶ms, bool compress) {
3162
+ inline std::shared_ptr<Response> Client::Post (const char *path,
3163
+ const Headers &headers,
3164
+ const Params ¶ms,
3165
+ bool compress) {
3158
3166
std::string query;
3159
3167
for (auto it = params.begin (); it != params.end (); ++it) {
3160
3168
if (it != params.begin ()) { query += " &" ; }
@@ -3163,11 +3171,13 @@ Client::Post(const char *path, const Headers &headers, const Params ¶ms, boo
3163
3171
query += detail::encode_url (it->second );
3164
3172
}
3165
3173
3166
- return Post (path, headers, query, " application/x-www-form-urlencoded" , compress);
3174
+ return Post (path, headers, query, " application/x-www-form-urlencoded" ,
3175
+ compress);
3167
3176
}
3168
3177
3169
3178
inline std::shared_ptr<Response>
3170
- Client::Post (const char *path, const MultipartFormDataItems &items, bool compress) {
3179
+ Client::Post (const char *path, const MultipartFormDataItems &items,
3180
+ bool compress) {
3171
3181
return Post (path, Headers (), items, compress);
3172
3182
}
3173
3183
@@ -3205,11 +3215,9 @@ inline std::shared_ptr<Response> Client::Put(const char *path,
3205
3215
return Put (path, Headers (), body, content_type, compress);
3206
3216
}
3207
3217
3208
- inline std::shared_ptr<Response> Client::Put (const char *path,
3209
- const Headers &headers,
3210
- const std::string &body,
3211
- const char *content_type,
3212
- bool compress) {
3218
+ inline std::shared_ptr<Response>
3219
+ Client::Put (const char *path, const Headers &headers, const std::string &body,
3220
+ const char *content_type, bool compress) {
3213
3221
Request req;
3214
3222
req.method = " PUT" ;
3215
3223
req.headers = headers;
@@ -3219,9 +3227,7 @@ inline std::shared_ptr<Response> Client::Put(const char *path,
3219
3227
req.body = body;
3220
3228
3221
3229
if (compress) {
3222
- if (!detail::compress (req.body )) {
3223
- return nullptr ;
3224
- }
3230
+ if (!detail::compress (req.body )) { return nullptr ; }
3225
3231
req.headers .emplace (" Content-Encoding" , " gzip" );
3226
3232
}
3227
3233
@@ -3237,11 +3243,9 @@ inline std::shared_ptr<Response> Client::Patch(const char *path,
3237
3243
return Patch (path, Headers (), body, content_type, compress);
3238
3244
}
3239
3245
3240
- inline std::shared_ptr<Response> Client::Patch (const char *path,
3241
- const Headers &headers,
3242
- const std::string &body,
3243
- const char *content_type,
3244
- bool compress) {
3246
+ inline std::shared_ptr<Response>
3247
+ Client::Patch (const char *path, const Headers &headers, const std::string &body,
3248
+ const char *content_type, bool compress) {
3245
3249
Request req;
3246
3250
req.method = " PATCH" ;
3247
3251
req.headers = headers;
@@ -3251,9 +3255,7 @@ inline std::shared_ptr<Response> Client::Patch(const char *path,
3251
3255
req.body = body;
3252
3256
3253
3257
if (compress) {
3254
- if (!detail::compress (req.body )) {
3255
- return nullptr ;
3256
- }
3258
+ if (!detail::compress (req.body )) { return nullptr ; }
3257
3259
req.headers .emplace (" Content-Encoding" , " gzip" );
3258
3260
}
3259
3261
0 commit comments