Begin work on new streams API

This commit is contained in:
Alex Hultman
2018-09-20 21:51:54 +02:00
parent 099f162576
commit 932b0b8944
4 changed files with 191 additions and 15 deletions
+15 -1
View File
@@ -11,10 +11,24 @@ namespace uWS {
template <bool SSL>
struct HttpResponseData : HttpParser, AsyncSocketData<SSL> {
template <bool> friend struct HttpResponse;
template <bool> friend struct HttpContext;
private:
/* Bits of status */
enum {
HTTP_STATUS_SENT = 1,
HTTP_WRITE_CALLED = 2,
HTTP_KNOWN_STREAM_OUT_SIZE = 4,
HTTP_PAUSED_STREAM_OUT = 8
};
std::function<void(std::string_view)> inStream;
std::function<std::string_view(int)> outStream;
std::function<std::pair<bool, std::string_view>(int)> outStream;
/* Outgoing offset */
int offset = 0;
/* Current state (content-length sent, status sent, write called, etc */
int state = 0;
};
}