@@ -810,6 +810,7 @@ name: golang
810
810
const std::string METRIC{" metric" };
811
811
const std::string ACTION{" action" };
812
812
const std::string ADDDATA{" add_data" };
813
+ const std::string BUFFERFLUSH{" buffer_flush" };
813
814
};
814
815
815
816
INSTANTIATE_TEST_SUITE_P (IpVersions, GolangIntegrationTest,
@@ -1350,6 +1351,116 @@ TEST_P(GolangIntegrationTest, AddDataBufferAllDataAndAsync) {
1350
1351
cleanup ();
1351
1352
}
1352
1353
1354
+ TEST_P (GolangIntegrationTest, BufferFlush_InBufferedDownstreamRequest) {
1355
+ initializeBasicFilter (BUFFERFLUSH, " test.com" );
1356
+
1357
+ codec_client_ = makeHttpConnection (makeClientConnection (lookupPort (" http" )));
1358
+ Http::TestRequestHeaderMapImpl request_headers{{" :method" , " POST" },
1359
+ {" :path" , " /test?bufferingly_decode" },
1360
+ {" :scheme" , " http" },
1361
+ {" :authority" , " test.com" }};
1362
+
1363
+ auto encoder_decoder = codec_client_->startRequest (request_headers, false );
1364
+ Http::RequestEncoder& request_encoder = encoder_decoder.first ;
1365
+ codec_client_->sendData (request_encoder, " To " , false );
1366
+ codec_client_->sendData (request_encoder, " be, " , true );
1367
+
1368
+ waitForNextUpstreamRequest ();
1369
+
1370
+ auto body = " To be, or not to be, that is the question" ;
1371
+ EXPECT_EQ (body, upstream_request_->body ().toString ());
1372
+
1373
+ cleanup ();
1374
+ }
1375
+
1376
+ TEST_P (GolangIntegrationTest, BufferFlush_InNonBufferedDownstreamRequest) {
1377
+ initializeBasicFilter (BUFFERFLUSH, " test.com" );
1378
+
1379
+ codec_client_ = makeHttpConnection (makeClientConnection (lookupPort (" http" )));
1380
+ Http::TestRequestHeaderMapImpl request_headers{{" :method" , " POST" },
1381
+ {" :path" , " /test?nonbufferingly_decode" },
1382
+ {" :scheme" , " http" },
1383
+ {" :authority" , " test.com" }};
1384
+
1385
+ auto encoder_decoder = codec_client_->startRequest (request_headers, false );
1386
+ Http::RequestEncoder& request_encoder = encoder_decoder.first ;
1387
+ codec_client_->sendData (request_encoder, " To be, " , false );
1388
+ timeSystem ().advanceTimeAndRun (std::chrono::milliseconds (10 ), *dispatcher_,
1389
+ Event::Dispatcher::RunType::NonBlock);
1390
+ codec_client_->sendData (request_encoder, " that is " , true );
1391
+
1392
+ waitForNextUpstreamRequest ();
1393
+
1394
+ auto body = " To be, or not to be, that is the question" ;
1395
+ EXPECT_EQ (body, upstream_request_->body ().toString ());
1396
+
1397
+ cleanup ();
1398
+ }
1399
+
1400
+ TEST_P (GolangIntegrationTest, BufferFlush_InBufferedUpstreamResponse) {
1401
+ initializeBasicFilter (BUFFERFLUSH, " test.com" );
1402
+
1403
+ codec_client_ = makeHttpConnection (makeClientConnection (lookupPort (" http" )));
1404
+ Http::TestRequestHeaderMapImpl request_headers{{" :method" , " POST" },
1405
+ {" :path" , " /test?bufferingly_encode" },
1406
+ {" :scheme" , " http" },
1407
+ {" :authority" , " test.com" }};
1408
+
1409
+ auto encoder_decoder = codec_client_->startRequest (request_headers, true );
1410
+ auto response = std::move (encoder_decoder.second );
1411
+
1412
+ waitForNextUpstreamRequest ();
1413
+
1414
+ Http::TestResponseHeaderMapImpl response_headers{
1415
+ {" :status" , " 200" },
1416
+ };
1417
+ upstream_request_->encodeHeaders (response_headers, false );
1418
+ Buffer::OwnedImpl response_data (" To " );
1419
+ upstream_request_->encodeData (response_data, false );
1420
+ Buffer::OwnedImpl response_data2 (" be, " );
1421
+ upstream_request_->encodeData (response_data2, true );
1422
+
1423
+ ASSERT_TRUE (response->waitForEndStream ());
1424
+
1425
+ auto body = " To be, or not to be, that is the question" ;
1426
+ EXPECT_EQ (body, response->body ());
1427
+
1428
+ cleanup ();
1429
+ }
1430
+
1431
+ TEST_P (GolangIntegrationTest, BufferFlush_InNonBufferedUpstreamResponse) {
1432
+ initializeBasicFilter (BUFFERFLUSH, " test.com" );
1433
+
1434
+ codec_client_ = makeHttpConnection (makeClientConnection (lookupPort (" http" )));
1435
+ Http::TestRequestHeaderMapImpl request_headers{{" :method" , " POST" },
1436
+ {" :path" , " /test?nonbufferingly_encode" },
1437
+ {" :scheme" , " http" },
1438
+ {" :authority" , " test.com" }};
1439
+
1440
+ auto encoder_decoder = codec_client_->startRequest (request_headers, true );
1441
+ auto response = std::move (encoder_decoder.second );
1442
+
1443
+ waitForNextUpstreamRequest ();
1444
+
1445
+ Http::TestResponseHeaderMapImpl response_headers{
1446
+ {" :status" , " 200" },
1447
+ };
1448
+ upstream_request_->encodeHeaders (response_headers, false );
1449
+ Buffer::OwnedImpl response_data (" To be, " );
1450
+ upstream_request_->encodeData (response_data, false );
1451
+ timeSystem ().advanceTimeAndRun (std::chrono::milliseconds (10 ), *dispatcher_,
1452
+ Event::Dispatcher::RunType::NonBlock);
1453
+ Buffer::OwnedImpl response_data2 (" that is " );
1454
+ upstream_request_->encodeData (response_data2, true );
1455
+
1456
+ ASSERT_TRUE (response->waitForEndStream ());
1457
+
1458
+ auto body = " To be, or not to be, that is the question" ;
1459
+ EXPECT_EQ (body, response->body ());
1460
+
1461
+ cleanup ();
1462
+ }
1463
+
1353
1464
// Buffer exceed limit in decode header phase.
1354
1465
TEST_P (GolangIntegrationTest, BufferExceedLimit_DecodeHeader) {
1355
1466
testBufferExceedLimit (" /test?databuffer=decode-header" );
0 commit comments