#ifndef MEMGRAPH_SERVER_HTTP_HTTPPARSER_HPP #define MEMGRAPH_SERVER_HTTP_HTTPPARSER_HPP #include #include #include namespace http { template class HttpConnection; template class HttpParserSettings; template class HttpParser { using connection_t = HttpConnection; using settings_t = HttpParserSettings; friend class HttpParserSettings; public: HttpParser(); static void init(); size_t execute(settings_t& settings, const char* data, size_t size); template T* data(); template void data(T* value); private: http_parser parser; std::string last_field; static int on_message_begin(http_parser* parser); static int on_url(http_parser* parser, const char* at, size_t length); static int on_status_complete(http_parser* parser, const char* at, size_t length); static int on_header_field(http_parser* parser, const char* at, size_t length); static int on_header_value(http_parser* parser, const char* at, size_t length); static int on_headers_complete(http_parser* parser); static int on_body(http_parser* parser, const char* at, size_t length); static int on_message_complete(http_parser* parser); }; } #endif