| 793 | |
| 794 | SC_TEST_EXPECT(response.sendRedirect(302, "/new-place")); |
| 795 | while (writable.flushOne()) {} |
| 796 | |
| 797 | constexpr StringView expected = "HTTP/1.1 302 Found\r\n" |
| 798 | "Content-Length: 0\r\n" |
| 799 | "Location: /new-place\r\n" |
| 800 | "Connection: keep-alive\r\n" |
| 801 | "\r\n"; |
| 802 | SC_TEST_EXPECT(StringSpan(writable.output.toSpanConst(), false, StringEncoding::Ascii) == expected); |
| 803 | } |
| 804 | |
| 805 | { |
| 806 | SC::AsyncBufferView buffers[4] = {}; |
| 807 | SC::AsyncBuffersPool pool; |
| 808 | pool.setBuffers(buffers); |
| 809 | |
| 810 | RecordedWritableStream writable; |
| 811 | SC_TEST_EXPECT(writable.init(pool)); |
| 812 | |
| 813 | ProbeHttpResponse response; |
| 814 | char headers[256] = {0}; |
| 815 | response.setup(headers, writable); |
| 816 | SC_TEST_EXPECT(not response.sendRedirect(200, "/not-a-redirect")); |
| 817 | |
| 818 | ProbeHttpResponse emptyLocationResponse; |
| 819 | emptyLocationResponse.setup(headers, writable); |
| 820 | SC_TEST_EXPECT(not emptyLocationResponse.sendRedirect(302, "")); |
| 821 | } |
| 822 | |
| 823 | { |
| 824 | SC::AsyncBufferView buffers[4] = {}; |
| 825 | SC::AsyncBuffersPool pool; |
| 826 | pool.setBuffers(buffers); |
| 827 | |
| 828 | RecordedWritableStream writable; |
| 829 | SC_TEST_EXPECT(writable.init(pool)); |
| 830 | |
| 831 | ProbeHttpResponse response; |
| 832 | char headers[256] = {0}; |
| 833 | response.setup(headers, writable); |
| 834 | |
| 835 | SC_TEST_EXPECT(response.sendMethodNotAllowed("GET, POST")); |
| 836 | while (writable.flushOne()) {} |
| 837 | |
| 838 | constexpr StringView expected = "HTTP/1.1 405 Method Not Allowed\r\n" |
| 839 | "Content-Length: 0\r\n" |
| 840 | "Allow: GET, POST\r\n" |
| 841 | "Connection: keep-alive\r\n" |
| 842 | "\r\n"; |
| 843 | SC_TEST_EXPECT(StringSpan(writable.output.toSpanConst(), false, StringEncoding::Ascii) == expected); |
| 844 | } |
| 845 | |
| 846 | { |
| 847 | SC::AsyncBufferView buffers[4] = {}; |
| 848 | SC::AsyncBuffersPool pool; |
| 849 | pool.setBuffers(buffers); |
| 850 | |
| 851 | RecordedWritableStream writable; |
| 852 | SC_TEST_EXPECT(writable.init(pool)); |
nothing calls this directly
no test coverage detected