MCPcopy Create free account
hub / github.com/boostorg/beast / testChunkedOverflow

Method testChunkedOverflow

test/beast/http/basic_parser.cpp:1458–1528  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1456 }
1457
1458 void
1459 testChunkedOverflow()
1460 {
1461 {
1462 const std::string hdr =
1463 "HTTP/1.1 200 OK" "\r\n"
1464 "Server: test" "\r\n"
1465 "Transfer-Encoding: chunked" "\r\n"
1466 "\r\n";
1467 const std::string chunk1 =
1468 "10000000000000000" "\r\n"
1469 "data...";
1470 test_parser<false> p;
1471 error_code ec;
1472 p.put(net::buffer(hdr), ec);
1473 BEAST_EXPECT(!ec);
1474 BEAST_EXPECT(p.is_header_done());
1475 auto bt = p.put(net::buffer(chunk1), ec);
1476 BEAST_EXPECT(bt == 0);
1477 BEAST_EXPECT(ec == error::bad_chunk);
1478 }
1479 {
1480 const std::string hdr =
1481 "HTTP/1.1 200 OK" "\r\n"
1482 "Server: test" "\r\n"
1483 "Transfer-Encoding: chunked" "\r\n"
1484 "\r\n"
1485 "1" "\r\n"
1486 "x" "\r\n";
1487 const std::string chunk2 =
1488 "FFFFFFFFFFFFFFFF" "\r\n"
1489 "data...";
1490 test_parser<false> p;
1491 p.eager(true);
1492 error_code ec;
1493 flat_buffer fb;
1494 fb.commit(net::buffer_copy(fb.prepare(10000), net::buffer(hdr)));
1495 fb.consume(p.put(fb.data(), ec));
1496 BEAST_EXPECT(p.is_header_done());
1497 BEAST_EXPECT(ec = error::need_more);
1498 fb.commit(net::buffer_copy(fb.prepare(10000), net::buffer(chunk2)));
1499 auto bt = p.put(fb.data(), ec);
1500 BEAST_EXPECT(bt == 0);
1501 BEAST_EXPECT(ec == error::body_limit);
1502 }
1503 {
1504 const std::string hdr =
1505 "HTTP/1.1 200 OK" "\r\n"
1506 "Server: test" "\r\n"
1507 "Transfer-Encoding: chunked" "\r\n"
1508 "\r\n"
1509 "1" "\r\n"
1510 "x" "\r\n";
1511 const std::string chunk2 =
1512 "FFFFFFFFFFFFFFFF" "\r\n"
1513 "data...";
1514 test_parser<false> p;
1515 p.eager(true);

Callers

nothing calls this directly

Calls 9

eagerMethod · 0.80
body_limitMethod · 0.80
messageMethod · 0.80
putMethod · 0.45
is_header_doneMethod · 0.45
commitMethod · 0.45
prepareMethod · 0.45
consumeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected