24 #define HTTP_PARSER_VERSION_MAJOR 1 25 #define HTTP_PARSER_VERSION_MINOR 0 27 #include <sys/types.h> 28 #if defined(_WIN32) && !defined(__MINGW32__) && \ 29 (!defined(_MSC_VER) || _MSC_VER<1600) && !defined(__WINE__) 33 typedef unsigned __int8
uint8_t;
51 #ifndef HTTP_PARSER_STRICT 52 # define HTTP_PARSER_STRICT 0 58 #ifndef HTTP_PARSER_DEBUG 59 # define HTTP_PARSER_DEBUG 0 64 #define HTTP_MAX_HEADER_SIZE (80*1024) 139 #define HTTP_ERRNO_MAP(XX) \ 144 XX(CB_message_begin, "the on_message_begin callback failed") \ 145 XX(CB_path, "the on_path callback failed") \ 146 XX(CB_query_string, "the on_query_string callback failed") \ 147 XX(CB_url, "the on_url callback failed") \ 148 XX(CB_fragment, "the on_fragment callback failed") \ 149 XX(CB_header_field, "the on_header_field callback failed") \ 150 XX(CB_header_value, "the on_header_value callback failed") \ 151 XX(CB_headers_complete, "the on_headers_complete callback failed") \ 152 XX(CB_body, "the on_body callback failed") \ 153 XX(CB_message_complete, "the on_message_complete callback failed") \ 154 XX(CB_reason, "the on_reason callback failed") \ 155 XX(CB_chunk_header, "the on_chunk_header callback failed") \ 156 XX(CB_chunk_complete, "the on_chunk_complete callback failed") \ 159 XX(INVALID_EOF_STATE, "stream ended at an unexpected time") \ 160 XX(HEADER_OVERFLOW, \ 161 "too many header bytes seen; overflow detected") \ 162 XX(CLOSED_CONNECTION, \ 163 "data received after completed connection: close message") \ 164 XX(INVALID_VERSION, "invalid HTTP version") \ 165 XX(INVALID_STATUS, "invalid HTTP status code") \ 166 XX(INVALID_METHOD, "invalid HTTP method") \ 167 XX(INVALID_URL, "invalid URL") \ 168 XX(INVALID_HOST, "invalid host") \ 169 XX(INVALID_PORT, "invalid port") \ 170 XX(INVALID_PATH, "invalid path") \ 171 XX(INVALID_QUERY_STRING, "invalid query string") \ 172 XX(INVALID_FRAGMENT, "invalid fragment") \ 173 XX(LF_EXPECTED, "LF character expected") \ 174 XX(INVALID_HEADER_TOKEN, "invalid character in header") \ 175 XX(INVALID_CONTENT_LENGTH, \ 176 "invalid character in content-length header") \ 177 XX(HUGE_CONTENT_LENGTH, \ 178 "content-length header too large") \ 179 XX(INVALID_CHUNK_SIZE, \ 180 "invalid character in chunk size header") \ 181 XX(HUGE_CHUNK_SIZE, \ 182 "chunk header size too large") \ 183 XX(INVALID_TRANSFER_ENCODING, \ 184 "invalid character in transfer-encoding header") \ 185 XX(INVALID_UPGRADE, \ 186 "invalid character in upgrade header") \ 187 XX(INVALID_CONSTANT, "invalid constant string") \ 188 XX(INVALID_INTERNAL_STATE, "encountered unexpected internal state")\ 189 XX(STRICT, "strict mode assertion failed") \ 190 XX(PAUSED, "parser is paused") \ 191 XX(UNKNOWN, "an unknown error occurred") 195 #define HTTP_ERRNO_GEN(n, s) HPE_##n, 199 #undef HTTP_ERRNO_GEN 203 #define HTTP_PARSER_ERRNO(p) ((enum http_errno) (p)->http_errno) 206 #if HTTP_PARSER_DEBUG 207 #define HTTP_PARSER_ERRNO_LINE(p) ((p)->error_lineno) 209 #define HTTP_PARSER_ERRNO_LINE(p) 0 218 unsigned char header_state;
225 unsigned short http_major;
226 unsigned short http_minor;
227 unsigned short status_code;
228 unsigned char method;
238 #if HTTP_PARSER_DEBUG
int(* http_cb)(http_parser *)
#define HTTP_ERRNO_MAP(XX)
struct http_parser_result http_parser_result
const char * http_method_str(enum http_method m)
void http_parser_pause(http_parser *parser, int paused)
static http_parser_settings settings
static http_parser * parser
size_t http_parser_execute(http_parser *parser, const http_parser_settings *settings, const char *data, size_t len)
static map< string, int > m
int http_parser_parse_url(const char *buf, size_t buflen, int is_connect, struct http_parser_url *u)
#define HTTP_ERRNO_GEN(n, s)
int(* http_data_cb)(http_parser *, const char *at, size_t length)
const char * http_errno_name(enum http_errno err)
const char * http_errno_description(enum http_errno err)
static constexpr uint64_t data[1]
void http_parser_init(http_parser *parser, enum http_parser_type type)