| 103 | } |
| 104 | |
| 105 | void receiveEchoBody(HttpConnection& connection) |
| 106 | { |
| 107 | SC_ASSERT_RELEASE(connection.response.startResponse(200)); |
| 108 | SC_ASSERT_RELEASE(connection.response.addHeader("Content-Type", HttpContentTypeTextPlainUtf8())); |
| 109 | if (connection.request.getBodyFramingKind() == HttpBodyFramingKind::ContentLength) |
| 110 | { |
| 111 | SC_ASSERT_RELEASE(connection.response.addContentLength(connection.request.getBodyBytesRemaining())); |
| 112 | } |
| 113 | else |
| 114 | { |
| 115 | connection.response.setKeepAlive(false); |
| 116 | } |
| 117 | SC_ASSERT_RELEASE(connection.response.sendHeaders()); |
| 118 | |
| 119 | if (connection.request.getBodyFramingKind() == HttpBodyFramingKind::None or |
| 120 | (connection.request.getBodyFramingKind() == HttpBodyFramingKind::ContentLength and |
| 121 | connection.request.getBodyBytesRemaining() == 0)) |
| 122 | { |
| 123 | SC_ASSERT_RELEASE(connection.response.end()); |
| 124 | return; |
| 125 | } |
| 126 | |
| 127 | connection.pipeline.source = &connection.request.getReadableStream(); |
| 128 | connection.pipeline.sinks[0] = &connection.response.getWritableStream(); |
| 129 | SC_ASSERT_RELEASE(connection.pipeline.pipe()); |
| 130 | SC_ASSERT_RELEASE(connection.pipeline.start()); |
| 131 | } |
| 132 | |
| 133 | Result notFound(HttpConnection& connection) { return connection.sendTextCopy(404, "not found\n"); } |
| 134 | }; |
nothing calls this directly
no test coverage detected