12#ifndef O2_FRAMEWORK_HTTPPARSER_H_
13#define O2_FRAMEWORK_HTTPPARSER_H_
17#include <fmt/format.h>
26template <std::endian E>
31 unsigned char opcode : 4;
32 unsigned char rsv3 : 1;
33 unsigned char rsv2 : 1;
34 unsigned char rsv1 : 1;
35 unsigned char fin : 1;
36 unsigned char len : 7;
37 unsigned char mask : 1;
42 unsigned char fin : 1;
43 unsigned char rsv1 : 1;
44 unsigned char rsv2 : 1;
45 unsigned char rsv3 : 1;
46 unsigned char opcode : 4;
47 unsigned char mask : 1;
48 unsigned char len : 7;
51template <std::endian E>
56 unsigned char opcode : 4;
57 unsigned char rsv3 : 1;
58 unsigned char rsv2 : 1;
59 unsigned char rsv1 : 1;
60 unsigned char fin : 1;
61 unsigned char len : 7;
62 unsigned char mask : 1;
68 unsigned char fin : 1;
69 unsigned char rsv1 : 1;
70 unsigned char rsv2 : 1;
71 unsigned char rsv3 : 1;
72 unsigned char opcode : 4;
73 unsigned char mask : 1;
74 unsigned char len : 7;
78template <std::endian E>
83 unsigned char opcode : 4;
84 unsigned char rsv3 : 1;
85 unsigned char rsv2 : 1;
86 unsigned char rsv1 : 1;
87 unsigned char fin : 1;
88 unsigned char len : 7;
89 unsigned char mask : 1;
95 unsigned char fin : 1;
96 unsigned char rsv1 : 1;
97 unsigned char rsv2 : 1;
98 unsigned char rsv3 : 1;
99 unsigned char opcode : 4;
100 unsigned char mask : 1;
101 unsigned char len : 7;
136 std::vector<std::pair<std::string, std::string>> headers = {});
220 virtual void method(std::string_view
const& s) {};
221 virtual void target(std::string_view
const& s) {};
222 virtual void version(std::string_view
const& s) {};
223 virtual void header(std::string_view
const& k, std::string_view
const&
v) {};
GLsizei const GLchar *const * path
GLenum GLenum GLsizei len
Defining ITS Vertex explicitly as messageable.
@ IN_SEPARATOR
capture until a specific "separator"
@ IN_CAPTURE_SEPARATOR
capture until any or the "delimiters" characters
@ IN_CHUNKED
skip a specific "separator"
@ IN_CAPTURE_DELIMITERS
skip any "delimiters" char.
void encode_websocket_frames(std::vector< uv_buf_t > &outputs, char const *src, size_t size, WebSocketOpCode opcode, uint32_t mask)
std::pair< std::string, unsigned short > parse_websocket_url(char const *url)
void parse_http_request(char *start, size_t size, HTTPParser *parser)
std::string encode_websocket_handshake_request(const char *endpoint, const char *protocol, int version, char const *nonce, std::vector< std::pair< std::string, std::string > > headers)
void decode_websocket(char *start, size_t size, WebSocketHandler &handler)
std::string encode_websocket_handshake_reply(char const *nonce, const char *protocol)
static std::string calculateAccept(const char *nonce)
Helper to calculate the reply to a nonce.
virtual void replyVersion(std::string_view const &s)
virtual void header(std::string_view const &k, std::string_view const &v)
virtual void method(std::string_view const &s)
virtual void replyCode(std::string_view const &s)
virtual void endHeaders()
virtual void body(char *data, size_t s)
virtual void target(std::string_view const &s)
std::vector< HTTPState > states
virtual void replyMessage(std::string_view const &s)
virtual void version(std::string_view const &s)
static constexpr size_t MaxChunkSize
An handler for a websocket message stream.
size_t pendingHeaderSize
Bytes from an incomplete header.
virtual void endChunk()
Invoked whenever we have no more input to process.
virtual void frame(char const *frame, size_t s)
char * pendingBuffer
A buffer large enough to contain the next frame to be processed.
virtual ~WebSocketHandler()=default
virtual void control(char const *frame, size_t s)
FIXME: not implemented.
size_t remainingSize
Bytes which are still to be received for the previous, half delivered frame.
size_t pendingSize
Bytes which are already there from the previous, half delivered frame.
virtual void headers(std::map< std::string, std::string > const &headers)
Invoked when all the headers are received.
virtual void beginChunk()
Invoked before processing the next round of input.
virtual void beginFragmentation()
FIXME: not implemented.
virtual void endFragmentation()
FIXME: not implemented.