MCPcopy
hub / github.com/probelabs/goreplay / TEST_httpBodyParam

Function TEST_httpBodyParam

middleware/middleware.js:629–658  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

627}
628
629function TEST_httpBodyParam() {
630 let p = Buffer.from("POST / HTTP/1.1\r\n\r\n");
631
632 if (httpBodyParam(p, "test")) {
633 return fail("Should not found param")
634 }
635
636 p = setHttpBodyParam(p, "test", "123");
637 if (httpBody(p).toString() != "test=123") {
638 return fail("Should set first param: " + httpBody(p).toString());
639 }
640
641 if (httpBodyParam(p, "test") != "123") {
642 return fail("Should get first param: " + httpBodyParam(p, "test"));
643 }
644
645 p = setHttpBodyParam(p, "qwer", "ty");
646 if (httpBody(p).toString() != "test=123&qwer=ty") {
647 return fail("Should set second param: " + httpBody(p).toString());
648 }
649
650 p = setHttpBodyParam(p, "test", "4321");
651 if (httpBody(p).toString() != "test=4321&qwer=ty") {
652 return fail("Should update first param: " + httpBody(p).toString());
653 }
654
655 if (httpBodyParam(p, "test") != "4321") {
656 return fail("Should update first param: " + httpBody(p).toString());
657 }
658}
659
660function TEST_httpHeader() {
661 const examplePayload = "GET / HTTP/1.1\r\nHost: localhost:3000\r\nUser-Agent: Node\r\nContent-Length:5\r\n\r\nhello";

Callers

nothing calls this directly

Calls 4

httpBodyParamFunction · 0.85
failFunction · 0.85
setHttpBodyParamFunction · 0.85
httpBodyFunction · 0.85

Tested by

no test coverage detected