()
| 627 | } |
| 628 | |
| 629 | function 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 | |
| 660 | function 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"; |
nothing calls this directly
no test coverage detected