12#ifndef O2_FRAMEWORK_HTTPPARSER_H_
13#define O2_FRAMEWORK_HTTPPARSER_H_
16#include <fmt/format.h>
26#if O2_HOST_BYTE_ORDER == O2_LITTLE_ENDIAN
27 unsigned char opcode : 4;
28 unsigned char rsv3 : 1;
29 unsigned char rsv2 : 1;
30 unsigned char rsv1 : 1;
31 unsigned char fin : 1;
32 unsigned char len : 7;
33 unsigned char mask : 1;
34#elif O2_HOST_BYTE_ORDER == O2_BIG_ENDIAN
35 unsigned char fin : 1;
36 unsigned char rsv1 : 1;
37 unsigned char rsv2 : 1;
38 unsigned char rsv3 : 1;
39 unsigned char opcode : 4;
40 unsigned char mask : 1;
41 unsigned char len : 7;
43#error Uknown endiannes
48#if O2_HOST_BYTE_ORDER == O2_LITTLE_ENDIAN
49 unsigned char opcode : 4;
50 unsigned char rsv3 : 1;
51 unsigned char rsv2 : 1;
52 unsigned char rsv1 : 1;
53 unsigned char fin : 1;
54 unsigned char len : 7;
55 unsigned char mask : 1;
56#elif O2_HOST_BYTE_ORDER == O2_BIG_ENDIAN
57 unsigned char fin : 1;
58 unsigned char rsv1 : 1;
59 unsigned char rsv2 : 1;
60 unsigned char rsv3 : 1;
61 unsigned char opcode : 4;
62 unsigned char mask : 1;
63 unsigned char len : 7;
65#error Uknown endiannes
71#if O2_HOST_BYTE_ORDER == O2_LITTLE_ENDIAN
72 unsigned char opcode : 4;
73 unsigned char rsv3 : 1;
74 unsigned char rsv2 : 1;
75 unsigned char rsv1 : 1;
76 unsigned char fin : 1;
77 unsigned char len : 7;
78 unsigned char mask : 1;
79#elif O2_HOST_BYTE_ORDER == O2_BIG_ENDIAN
80 unsigned char fin : 1;
81 unsigned char rsv1 : 1;
82 unsigned char rsv2 : 1;
83 unsigned char rsv3 : 1;
84 unsigned char opcode : 4;
85 unsigned char mask : 1;
86 unsigned char len : 7;
88#error Uknown endiannes
124 std::vector<std::pair<std::string, std::string>> headers = {});
207 virtual void method(std::string_view
const& s){};
208 virtual void target(std::string_view
const& s){};
209 virtual void version(std::string_view
const& s){};
210 virtual void header(std::string_view
const& k, std::string_view
const&
v){};
GLsizei const GLchar *const * path
GLenum GLenum GLsizei len
Defining PrimaryVertex 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)
std::string encode_websocket_handshake_reply(char const *nonce)
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)
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.