mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-22 11:46:13 +00:00
Send the chunk overhead test requests whole before they are refused
RejectsChunkOverheadPastItsLimit sent about 78 KB per case, and the server refused the request a few chunks in and closed the connection while the client was still writing, so the send failed now and then instead of returning the 400. Pad each size line with a sixteenth of the limit, so each request is about 10 KB and goes past the limit only at its last chunks.
This commit is contained in:
1 parent
e121385910
commit
1e35f39675
1 file changed
+5
-3
+5
-3
@@ -8076,9 +8076,11 @@ TEST_F(ServerTest, RejectsControlCharacterInChunkExtension) {
|
|||||||
// The bytes around chunk data are no payload, so they cannot ride on the
|
// The bytes around chunk data are no payload, so they cannot ride on the
|
||||||
// payload limit
|
// payload limit
|
||||||
TEST_F(ServerTest, RejectsChunkOverheadPastItsLimit) {
|
TEST_F(ServerTest, RejectsChunkOverheadPastItsLimit) {
|
||||||
auto pad = std::string(CPPHTTPLIB_HEADER_MAX_LENGTH / 2, 'x');
|
// Small enough that the whole request is sent before the server turns it
|
||||||
auto zeros = std::string(CPPHTTPLIB_HEADER_MAX_LENGTH / 2, '0');
|
// down, yet past the limit by the last chunks
|
||||||
auto spaces = std::string(CPPHTTPLIB_HEADER_MAX_LENGTH / 2, ' ');
|
auto pad = std::string(CPPHTTPLIB_HEADER_MAX_LENGTH / 16, 'x');
|
||||||
|
auto zeros = std::string(CPPHTTPLIB_HEADER_MAX_LENGTH / 16, '0');
|
||||||
|
auto spaces = std::string(CPPHTTPLIB_HEADER_MAX_LENGTH / 16, ' ');
|
||||||
for (const auto &size_line : {"1;" + pad, zeros + "1", "1" + spaces}) {
|
for (const auto &size_line : {"1;" + pad, zeros + "1", "1" + spaces}) {
|
||||||
SCOPED_TRACE(size_line.substr(0, 2));
|
SCOPED_TRACE(size_line.substr(0, 2));
|
||||||
std::string body;
|
std::string body;
|
||||||
|
|||||||
Reference in new issue
Block a user