@@ -5302,11 +5302,13 @@ TEST_F(ServerTest, PatchContentReceiver) {
5302
5302
ASSERT_EQ (" content" , res->body );
5303
5303
}
5304
5304
5305
- template <typename ClientType>
5305
+ template <typename ClientType>
5306
5306
void TestWithHeadersAndContentReceiver (
5307
- ClientType& cli,
5308
- std::function<Result(ClientType&, const std::string&, const Headers&, const std::string&, const std::string&,
5309
- ContentReceiver, DownloadProgress)> request_func) {
5307
+ ClientType &cli,
5308
+ std::function<Result(ClientType &, const std::string &, const Headers &,
5309
+ const std::string &, const std::string &,
5310
+ ContentReceiver, DownloadProgress)>
5311
+ request_func) {
5310
5312
Headers headers;
5311
5313
headers.emplace (" X-Custom-Header" , " test-value" );
5312
5314
@@ -5316,7 +5318,8 @@ void TestWithHeadersAndContentReceiver(
5316
5318
[&](const char *data, size_t data_length) {
5317
5319
received_body.append (data, data_length);
5318
5320
return true ;
5319
- }, nullptr );
5321
+ },
5322
+ nullptr );
5320
5323
5321
5324
ASSERT_TRUE (res);
5322
5325
EXPECT_EQ (StatusCode::OK_200, res->status );
@@ -5329,11 +5332,12 @@ TEST_F(ServerTest, PostWithHeadersAndContentReceiver) {
5329
5332
#else
5330
5333
using ClientT = Client;
5331
5334
#endif
5332
- TestWithHeadersAndContentReceiver<ClientT>(cli_,
5333
- [](ClientT& cli, const std::string& path, const Headers& headers, const std::string& body,
5334
- const std::string& content_type, ContentReceiver receiver, DownloadProgress progress) {
5335
- return cli.Post (path, headers, body, content_type, receiver, progress);
5336
- });
5335
+ TestWithHeadersAndContentReceiver<ClientT>(
5336
+ cli_, [](ClientT &cli, const std::string &path, const Headers &headers,
5337
+ const std::string &body, const std::string &content_type,
5338
+ ContentReceiver receiver, DownloadProgress progress) {
5339
+ return cli.Post (path, headers, body, content_type, receiver, progress);
5340
+ });
5337
5341
}
5338
5342
5339
5343
TEST_F (ServerTest, PutWithHeadersAndContentReceiver) {
@@ -5342,11 +5346,12 @@ TEST_F(ServerTest, PutWithHeadersAndContentReceiver) {
5342
5346
#else
5343
5347
using ClientT = Client;
5344
5348
#endif
5345
- TestWithHeadersAndContentReceiver<ClientT>(cli_,
5346
- [](ClientT& cli, const std::string& path, const Headers& headers, const std::string& body,
5347
- const std::string& content_type, ContentReceiver receiver, DownloadProgress progress) {
5348
- return cli.Put (path, headers, body, content_type, receiver, progress);
5349
- });
5349
+ TestWithHeadersAndContentReceiver<ClientT>(
5350
+ cli_, [](ClientT &cli, const std::string &path, const Headers &headers,
5351
+ const std::string &body, const std::string &content_type,
5352
+ ContentReceiver receiver, DownloadProgress progress) {
5353
+ return cli.Put (path, headers, body, content_type, receiver, progress);
5354
+ });
5350
5355
}
5351
5356
5352
5357
TEST_F (ServerTest, PatchWithHeadersAndContentReceiver) {
@@ -5355,18 +5360,21 @@ TEST_F(ServerTest, PatchWithHeadersAndContentReceiver) {
5355
5360
#else
5356
5361
using ClientT = Client;
5357
5362
#endif
5358
- TestWithHeadersAndContentReceiver<ClientT>(cli_,
5359
- [](ClientT& cli, const std::string& path, const Headers& headers, const std::string& body,
5360
- const std::string& content_type, ContentReceiver receiver, DownloadProgress progress) {
5361
- return cli.Patch (path, headers, body, content_type, receiver, progress);
5362
- });
5363
+ TestWithHeadersAndContentReceiver<ClientT>(
5364
+ cli_, [](ClientT &cli, const std::string &path, const Headers &headers,
5365
+ const std::string &body, const std::string &content_type,
5366
+ ContentReceiver receiver, DownloadProgress progress) {
5367
+ return cli.Patch (path, headers, body, content_type, receiver, progress);
5368
+ });
5363
5369
}
5364
5370
5365
- template <typename ClientType>
5371
+ template <typename ClientType>
5366
5372
void TestWithHeadersAndContentReceiverWithProgress (
5367
- ClientType& cli,
5368
- std::function<Result(ClientType&, const std::string&, const Headers&, const std::string&, const std::string&,
5369
- ContentReceiver, DownloadProgress)> request_func) {
5373
+ ClientType &cli,
5374
+ std::function<Result(ClientType &, const std::string &, const Headers &,
5375
+ const std::string &, const std::string &,
5376
+ ContentReceiver, DownloadProgress)>
5377
+ request_func) {
5370
5378
Headers headers;
5371
5379
headers.emplace (" X-Test-Header" , " progress-test" );
5372
5380
@@ -5396,11 +5404,12 @@ TEST_F(ServerTest, PostWithHeadersAndContentReceiverWithProgress) {
5396
5404
#else
5397
5405
using ClientT = Client;
5398
5406
#endif
5399
- TestWithHeadersAndContentReceiverWithProgress<ClientT>(cli_,
5400
- [](ClientT& cli, const std::string& path, const Headers& headers, const std::string& body,
5401
- const std::string& content_type, ContentReceiver receiver, DownloadProgress progress) {
5402
- return cli.Post (path, headers, body, content_type, receiver, progress);
5403
- });
5407
+ TestWithHeadersAndContentReceiverWithProgress<ClientT>(
5408
+ cli_, [](ClientT &cli, const std::string &path, const Headers &headers,
5409
+ const std::string &body, const std::string &content_type,
5410
+ ContentReceiver receiver, DownloadProgress progress) {
5411
+ return cli.Post (path, headers, body, content_type, receiver, progress);
5412
+ });
5404
5413
}
5405
5414
5406
5415
TEST_F (ServerTest, PutWithHeadersAndContentReceiverWithProgress) {
@@ -5409,11 +5418,12 @@ TEST_F(ServerTest, PutWithHeadersAndContentReceiverWithProgress) {
5409
5418
#else
5410
5419
using ClientT = Client;
5411
5420
#endif
5412
- TestWithHeadersAndContentReceiverWithProgress<ClientT>(cli_,
5413
- [](ClientT& cli, const std::string& path, const Headers& headers, const std::string& body,
5414
- const std::string& content_type, ContentReceiver receiver, DownloadProgress progress) {
5415
- return cli.Put (path, headers, body, content_type, receiver, progress);
5416
- });
5421
+ TestWithHeadersAndContentReceiverWithProgress<ClientT>(
5422
+ cli_, [](ClientT &cli, const std::string &path, const Headers &headers,
5423
+ const std::string &body, const std::string &content_type,
5424
+ ContentReceiver receiver, DownloadProgress progress) {
5425
+ return cli.Put (path, headers, body, content_type, receiver, progress);
5426
+ });
5417
5427
}
5418
5428
5419
5429
TEST_F (ServerTest, PatchWithHeadersAndContentReceiverWithProgress) {
@@ -5422,31 +5432,33 @@ TEST_F(ServerTest, PatchWithHeadersAndContentReceiverWithProgress) {
5422
5432
#else
5423
5433
using ClientT = Client;
5424
5434
#endif
5425
- TestWithHeadersAndContentReceiverWithProgress<ClientT>(cli_,
5426
- [](ClientT& cli, const std::string& path, const Headers& headers, const std::string& body,
5427
- const std::string& content_type, ContentReceiver receiver, DownloadProgress progress) {
5428
- return cli.Patch (path, headers, body, content_type, receiver, progress);
5429
- });
5435
+ TestWithHeadersAndContentReceiverWithProgress<ClientT>(
5436
+ cli_, [](ClientT &cli, const std::string &path, const Headers &headers,
5437
+ const std::string &body, const std::string &content_type,
5438
+ ContentReceiver receiver, DownloadProgress progress) {
5439
+ return cli.Patch (path, headers, body, content_type, receiver, progress);
5440
+ });
5430
5441
}
5431
5442
5432
- template <typename ClientType>
5443
+ template <typename ClientType>
5433
5444
void TestWithHeadersAndContentReceiverError (
5434
- ClientType& cli,
5435
- std::function<Result(ClientType&, const std::string&, const Headers&, const std::string&, const std::string&,
5436
- ContentReceiver)> request_func) {
5445
+ ClientType &cli, std::function<Result(ClientType &, const std::string &,
5446
+ const Headers &, const std::string &,
5447
+ const std::string &, ContentReceiver)>
5448
+ request_func) {
5437
5449
Headers headers;
5438
5450
headers.emplace (" X-Error-Test" , " true" );
5439
5451
5440
5452
std::string received_body;
5441
5453
auto receiver_failed = false ;
5442
5454
5443
- auto res = request_func (
5444
- cli, " /content_receiver" , headers, " content" , " text/plain" ,
5445
- [&](const char *data, size_t data_length) {
5446
- received_body.append (data, data_length);
5447
- receiver_failed = true ;
5448
- return false ;
5449
- });
5455
+ auto res =
5456
+ request_func ( cli, " /content_receiver" , headers, " content" , " text/plain" ,
5457
+ [&](const char *data, size_t data_length) {
5458
+ received_body.append (data, data_length);
5459
+ receiver_failed = true ;
5460
+ return false ;
5461
+ });
5450
5462
5451
5463
ASSERT_FALSE (res);
5452
5464
EXPECT_TRUE (receiver_failed);
@@ -5458,11 +5470,12 @@ TEST_F(ServerTest, PostWithHeadersAndContentReceiverError) {
5458
5470
#else
5459
5471
using ClientT = Client;
5460
5472
#endif
5461
- TestWithHeadersAndContentReceiverError<ClientT>(cli_,
5462
- [](ClientT& cli, const std::string& path, const Headers& headers, const std::string& body,
5463
- const std::string& content_type, ContentReceiver receiver) {
5464
- return cli.Post (path, headers, body, content_type, receiver);
5465
- });
5473
+ TestWithHeadersAndContentReceiverError<ClientT>(
5474
+ cli_, [](ClientT &cli, const std::string &path, const Headers &headers,
5475
+ const std::string &body, const std::string &content_type,
5476
+ ContentReceiver receiver) {
5477
+ return cli.Post (path, headers, body, content_type, receiver);
5478
+ });
5466
5479
}
5467
5480
5468
5481
TEST_F (ServerTest, PuttWithHeadersAndContentReceiverError) {
@@ -5471,11 +5484,12 @@ TEST_F(ServerTest, PuttWithHeadersAndContentReceiverError) {
5471
5484
#else
5472
5485
using ClientT = Client;
5473
5486
#endif
5474
- TestWithHeadersAndContentReceiverError<ClientT>(cli_,
5475
- [](ClientT& cli, const std::string& path, const Headers& headers, const std::string& body,
5476
- const std::string& content_type, ContentReceiver receiver) {
5477
- return cli.Put (path, headers, body, content_type, receiver);
5478
- });
5487
+ TestWithHeadersAndContentReceiverError<ClientT>(
5488
+ cli_, [](ClientT &cli, const std::string &path, const Headers &headers,
5489
+ const std::string &body, const std::string &content_type,
5490
+ ContentReceiver receiver) {
5491
+ return cli.Put (path, headers, body, content_type, receiver);
5492
+ });
5479
5493
}
5480
5494
5481
5495
TEST_F (ServerTest, PatchWithHeadersAndContentReceiverError) {
@@ -5484,11 +5498,12 @@ TEST_F(ServerTest, PatchWithHeadersAndContentReceiverError) {
5484
5498
#else
5485
5499
using ClientT = Client;
5486
5500
#endif
5487
- TestWithHeadersAndContentReceiverError<ClientT>(cli_,
5488
- [](ClientT& cli, const std::string& path, const Headers& headers, const std::string& body,
5489
- const std::string& content_type, ContentReceiver receiver) {
5490
- return cli.Patch (path, headers, body, content_type, receiver);
5491
- });
5501
+ TestWithHeadersAndContentReceiverError<ClientT>(
5502
+ cli_, [](ClientT &cli, const std::string &path, const Headers &headers,
5503
+ const std::string &body, const std::string &content_type,
5504
+ ContentReceiver receiver) {
5505
+ return cli.Patch (path, headers, body, content_type, receiver);
5506
+ });
5492
5507
}
5493
5508
5494
5509
TEST_F (ServerTest, PostQueryStringAndBody) {
0 commit comments