proxygen
|
#include "proxygen/external/http_parser/http_parser.h"
#include <assert.h>
#include <stddef.h>
#include <limits.h>
#include <stdlib.h>
Go to the source code of this file.
Macros | |
#define | nullptr NULL |
#define | MIN(a, b) ((a) < (b) ? (a) : (b)) |
#define | SET_ERRNO(e) |
#define | RETURN(r) |
#define | _CALLBACK_NOTIFY(FOR, ER) |
#define | CALLBACK_NOTIFY(FOR) _CALLBACK_NOTIFY(FOR, p - data + 1) |
#define | CALLBACK_NOTIFY_NOADVANCE(FOR) _CALLBACK_NOTIFY(FOR, p - data) |
#define | _CALLBACK_DATA(FOR, LEN, ER) |
#define | CALLBACK_DATA(FOR) _CALLBACK_DATA(FOR, p - FOR##_mark, p - data + 1) |
#define | CALLBACK_DATA_NOADVANCE(FOR) _CALLBACK_DATA(FOR, p - FOR##_mark, p - data) |
#define | CALLBACK_SPACE(FOR) |
#define | MARK(FOR) |
#define | CONTENT_LENGTH "content-length" |
#define | TRANSFER_ENCODING "transfer-encoding" |
#define | UPGRADE "upgrade" |
#define | CHUNKED "chunked" |
#define | SPACE " " |
#define | T(v) v |
#define | PARSING_HEADER(state) (state <= s_headers_done) |
#define | CR '\r' |
#define | LF '\n' |
#define | QT '"' |
#define | BS '\\' |
#define | LOWER(c) (unsigned char)(c | 0x20) |
#define | TOKEN(c) (tokens[(unsigned char)c]) |
#define | IS_ALPHA(c) (LOWER(c) >= 'a' && LOWER(c) <= 'z') |
#define | IS_NUM(c) ((c) >= '0' && (c) <= '9') |
#define | IS_ALPHANUM(c) (IS_ALPHA(c) || IS_NUM(c)) |
#define | IS_HEX(c) (IS_NUM(c) || (LOWER(c) >= 'a' && LOWER(c) <= 'f')) |
#define | IS_MARK(c) |
#define | IS_USERINFO_CHAR(c) |
#define | IS_URL_CHAR(c) (normal_url_char[(unsigned char) (c)] || ((c) & 0x80)) |
#define | IS_HOST_CHAR(c) (IS_ALPHANUM(c) || (c) == '.' || (c) == '-' || (c) == '_') |
#define | IS_HEADER_CHAR(ch) (ch == CR || ch == LF || ch == 9 || ((unsigned char)ch > 31 && ch != 127)) |
#define | start_state (parser->type == HTTP_REQUEST ? s_pre_start_req : s_pre_start_res) |
#define | STRICT_CHECK(cond) |
#define | NEW_MESSAGE() start_state |
#define | HTTP_STRERROR_GEN(n, s) { "HPE_" #n, s }, |
#define | MOVE_THE_HEAD |
#define | MOVE_FAST |
Functions | |
static enum state | parse_url_char (enum state s, const char ch) |
size_t | http_parser_execute (http_parser *parser, const http_parser_settings *settings, const char *data, size_t len) |
const char * | http_method_str (enum http_method m) |
void | http_parser_init (http_parser *parser, enum http_parser_type t) |
const char * | http_errno_name (enum http_errno err) |
const char * | http_errno_description (enum http_errno err) |
static enum http_host_state | http_parse_host_char (enum http_host_state s, const char ch) |
static int | http_parse_host (const char *buf, struct http_parser_url *u, int found_at) |
int | http_parser_parse_url (const char *buf, size_t buflen, int is_connect, struct http_parser_url *u) |
void | http_parser_pause (http_parser *parser, int paused) |
Variables | |
static const char * | method_strings [] |
static const char | tokens [256] |
static const int8_t | unhex [256] |
static const uint8_t | normal_url_char [256] |
struct { | |
const char * name | |
const char * description | |
} | http_strerror_tab [] |
#define _CALLBACK_DATA | ( | FOR, | |
LEN, | |||
ER | |||
) |
Definition at line 92 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
#define _CALLBACK_NOTIFY | ( | FOR, | |
ER | |||
) |
Definition at line 70 of file http_parser_cpp.cpp.
#define BS '\\' |
Definition at line 398 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
#define CALLBACK_DATA | ( | FOR | ) | _CALLBACK_DATA(FOR, p - FOR##_mark, p - data + 1) |
Definition at line 111 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
#define CALLBACK_DATA_NOADVANCE | ( | FOR | ) | _CALLBACK_DATA(FOR, p - FOR##_mark, p - data) |
Definition at line 115 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
#define CALLBACK_NOTIFY | ( | FOR | ) | _CALLBACK_NOTIFY(FOR, p - data + 1) |
Definition at line 86 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
#define CALLBACK_NOTIFY_NOADVANCE | ( | FOR | ) | _CALLBACK_NOTIFY(FOR, p - data) |
Definition at line 89 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
#define CALLBACK_SPACE | ( | FOR | ) |
Definition at line 119 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
#define CHUNKED "chunked" |
Definition at line 145 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
#define CONTENT_LENGTH "content-length" |
Definition at line 142 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
#define CR '\r' |
Definition at line 395 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
Definition at line 435 of file http_parser_cpp.cpp.
Definition at line 401 of file http_parser_cpp.cpp.
Referenced by http_parser_execute(), and parse_url_char().
Definition at line 403 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
#define IS_HEADER_CHAR | ( | ch | ) | (ch == CR || ch == LF || ch == 9 || ((unsigned char)ch > 31 && ch != 127)) |
Verify that a char is a valid visible (printable) US-ASCII character or x80-FF
Definition at line 426 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
Definition at line 404 of file http_parser_cpp.cpp.
Referenced by http_parse_host_char(), and http_parser_execute().
Definition at line 418 of file http_parser_cpp.cpp.
Referenced by http_parse_host_char(), and http_parser_execute().
#define IS_MARK | ( | c | ) |
Definition at line 402 of file http_parser_cpp.cpp.
Referenced by http_parse_host_char(), and http_parser_execute().
#define IS_URL_CHAR | ( | c | ) | (normal_url_char[(unsigned char) (c)] || ((c) & 0x80)) |
Definition at line 416 of file http_parser_cpp.cpp.
Referenced by http_parser_execute(), and parse_url_char().
#define IS_USERINFO_CHAR | ( | c | ) |
Definition at line 408 of file http_parser_cpp.cpp.
Referenced by http_parse_host_char(), and parse_url_char().
#define LF '\n' |
Definition at line 396 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
Definition at line 399 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
#define MARK | ( | FOR | ) |
Definition at line 134 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
Definition at line 46 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
#define MOVE_FAST |
Referenced by http_parser_execute().
#define MOVE_THE_HEAD |
Referenced by http_parser_execute().
#define NEW_MESSAGE | ( | ) | start_state |
Definition at line 432 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
#define nullptr NULL |
Definition at line 41 of file http_parser_cpp.cpp.
#define PARSING_HEADER | ( | state | ) | (state <= s_headers_done) |
Definition at line 357 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
#define QT '"' |
Definition at line 397 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
#define RETURN | ( | r | ) |
Definition at line 63 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
#define SET_ERRNO | ( | e | ) |
Definition at line 57 of file http_parser_cpp.cpp.
Referenced by http_parser_execute(), and http_parser_pause().
#define SPACE " " |
Definition at line 146 of file http_parser_cpp.cpp.
#define start_state (parser->type == HTTP_REQUEST ? s_pre_start_req : s_pre_start_res) |
Definition at line 429 of file http_parser_cpp.cpp.
#define STRICT_CHECK | ( | cond | ) |
Definition at line 431 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
Definition at line 233 of file http_parser_cpp.cpp.
Definition at line 400 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
#define TRANSFER_ENCODING "transfer-encoding" |
Definition at line 143 of file http_parser_cpp.cpp.
Referenced by http_parser_execute().
#define UPGRADE "upgrade" |
Definition at line 144 of file http_parser_cpp.cpp.
enum header_states |
Definition at line 360 of file http_parser_cpp.cpp.
enum http_host_state |
Definition at line 379 of file http_parser_cpp.cpp.
enum state |
Definition at line 272 of file http_parser_cpp.cpp.
const char* http_errno_description | ( | enum http_errno | err | ) |
Definition at line 2187 of file http_parser_cpp.cpp.
References http_strerror_tab.
const char* http_errno_name | ( | enum http_errno | err | ) |
Definition at line 2181 of file http_parser_cpp.cpp.
References http_strerror_tab.
const char* http_method_str | ( | enum http_method | m | ) |
|
static |
Definition at line 2259 of file http_parser_cpp.cpp.
References http_parser_url::field_data, http_parser_url::field_set, http_parse_host_char(), http_parser_url::len, http_parser_url::off, s, s_http_host, s_http_host_dead, s_http_host_port, s_http_host_port_start, s_http_host_start, s_http_host_v6, s_http_host_v6_start, s_http_userinfo, s_http_userinfo_start, UF_HOST, UF_PORT, and UF_USERINFO.
Referenced by http_parser_parse_url().
|
static |
Definition at line 2194 of file http_parser_cpp.cpp.
References IS_HEX, IS_HOST_CHAR, IS_NUM, IS_USERINFO_CHAR, s_http_host, s_http_host_dead, s_http_host_port, s_http_host_port_start, s_http_host_start, s_http_host_v6, s_http_host_v6_end, s_http_host_v6_start, s_http_userinfo, and s_http_userinfo_start.
Referenced by http_parse_host().
size_t http_parser_execute | ( | http_parser * | parser, |
const http_parser_settings * | settings, | ||
const char * | data, | ||
size_t | len | ||
) |
Definition at line 603 of file http_parser_cpp.cpp.
References _CALLBACK_DATA, BS, c, CALLBACK_DATA, CALLBACK_DATA_NOADVANCE, CALLBACK_NOTIFY, CALLBACK_NOTIFY_NOADVANCE, CALLBACK_SPACE, ch, CHUNKED, CONTENT_LENGTH, http_parser::content_length, CR, data, folly::pushmi::operators::error(), F_CHUNKED, F_SKIPBODY, F_TRAILING, F_UPGRADE, http_parser::flags, h_content_length, h_general, h_general_and_quote, h_general_and_quote_and_escape, h_matching_content_length, h_matching_transfer_encoding, h_matching_transfer_encoding_chunked, h_matching_upgrade, h_transfer_encoding, h_transfer_encoding_chunked, h_upgrade, http_parser::header_state, HPE_CB_headers_complete, HPE_HEADER_OVERFLOW, HPE_HUGE_CHUNK_SIZE, HPE_HUGE_CONTENT_LENGTH, HPE_INVALID_CHUNK_SIZE, HPE_INVALID_CONSTANT, HPE_INVALID_CONTENT_LENGTH, HPE_INVALID_EOF_STATE, HPE_INVALID_FRAGMENT, HPE_INVALID_HEADER_TOKEN, HPE_INVALID_HOST, HPE_INVALID_INTERNAL_STATE, HPE_INVALID_METHOD, HPE_INVALID_PATH, HPE_INVALID_PORT, HPE_INVALID_QUERY_STRING, HPE_INVALID_STATUS, HPE_INVALID_TRANSFER_ENCODING, HPE_INVALID_UPGRADE, HPE_INVALID_URL, HPE_INVALID_VERSION, HPE_LF_EXPECTED, HPE_OK, HPE_STRICT, HPE_UNKNOWN, HTTP_CHECKOUT, HTTP_CONNECT, HTTP_COPY, HTTP_DELETE, http_parser::http_errno, HTTP_GET, HTTP_HEAD, HTTP_LOCK, http_parser::http_major, HTTP_MAX_HEADER_SIZE, HTTP_MERGE, http_parser::http_minor, HTTP_MKACTIVITY, HTTP_MKCOL, HTTP_MOVE, HTTP_MSEARCH, HTTP_NOTIFY, HTTP_OPTIONS, HTTP_PARSER_ERRNO, HTTP_PATCH, HTTP_POST, HTTP_PROPFIND, HTTP_PROPPATCH, HTTP_PUT, HTTP_REPORT, HTTP_REQUEST, HTTP_RESPONSE, HTTP_SUBSCRIBE, HTTP_TRACE, HTTP_UNLOCK, HTTP_UNSUBSCRIBE, http_parser::index, int8_t, IS_ALPHA, IS_ALPHANUM, IS_HEADER_CHAR, IS_HEX, IS_HOST_CHAR, IS_NUM, IS_URL_CHAR, LF, LOWER, MARK, http_parser::method, MIN, MOVE_FAST, MOVE_THE_HEAD, NEW_MESSAGE, http_parser::nread, http_parser_settings::on_headers_complete, PARSING_HEADER, QT, RETURN, s_body_identity, s_body_identity_eof, s_chunk_data, s_chunk_data_almost_done, s_chunk_data_done, s_chunk_parameters, s_chunk_size, s_chunk_size_almost_done, s_chunk_size_start, s_header_almost_done, s_header_field, s_header_field_start, s_header_value, s_header_value_lws, s_header_value_start, s_headers_almost_done, s_headers_done, s_message_done, s_pre_start_req, s_pre_start_req_or_res, s_pre_start_res, s_req_first_http_major, s_req_first_http_minor, s_req_fragment, s_req_fragment_start, s_req_host, s_req_host_done, s_req_host_ipv6, s_req_host_start, s_req_http_H, s_req_http_HT, s_req_http_HTT, s_req_http_HTTP, s_req_http_major, s_req_http_minor, s_req_http_start, s_req_line_almost_done, s_req_method, s_req_path, s_req_port, s_req_query_string, s_req_query_string_start, s_req_schema, s_req_schema_slash, s_req_schema_slash_slash, s_req_spaces_before_url, s_res_first_http_major, s_res_first_http_minor, s_res_first_status_code, s_res_H, s_res_HT, s_res_HTT, s_res_HTTP, s_res_http_major, s_res_http_minor, s_res_line_almost_done, s_res_or_resp_H, s_res_status, s_res_status_code, s_start_req, s_start_req_or_res, s_start_res, SET_ERRNO, http_parser::state, http_parser::status_code, STRICT_CHECK, TOKEN, TRANSFER_ENCODING, http_parser::type, uint64_t, UPGRADE, and http_parser::upgrade.
void http_parser_init | ( | http_parser * | parser, |
enum http_parser_type | t | ||
) |
Definition at line 2167 of file http_parser_cpp.cpp.
References http_parser::flags, HPE_OK, http_parser::http_errno, http_parser::http_major, http_parser::http_minor, HTTP_REQUEST, HTTP_RESPONSE, http_parser::method, http_parser::nread, s_pre_start_req, s_pre_start_req_or_res, s_pre_start_res, http_parser::state, folly::pushmi::detail::t, http_parser::type, and http_parser::upgrade.
int http_parser_parse_url | ( | const char * | buf, |
size_t | buflen, | ||
int | is_connect, | ||
struct http_parser_url * | u | ||
) |
Definition at line 2333 of file http_parser_cpp.cpp.
References http_parser_url::field_data, http_parser_url::field_set, http_parse_host(), http_parser_url::len, http_parser_url::off, parse_url_char(), http_parser_url::port, s, s_dead, s_req_fragment, s_req_fragment_start, s_req_path, s_req_query_string, s_req_query_string_start, s_req_schema, s_req_schema_slash, s_req_schema_slash_slash, s_req_server, s_req_server_start, s_req_server_with_at, s_req_spaces_before_url, UF_FRAGMENT, UF_HOST, UF_MAX, UF_PATH, UF_PORT, UF_QUERY, UF_SCHEMA, and uint16_t.
void http_parser_pause | ( | http_parser * | parser, |
int | paused | ||
) |
Definition at line 2432 of file http_parser_cpp.cpp.
References HPE_OK, HPE_PAUSED, HTTP_PARSER_ERRNO, and SET_ERRNO.
Definition at line 456 of file http_parser_cpp.cpp.
References IS_ALPHA, IS_URL_CHAR, IS_USERINFO_CHAR, s, s_dead, s_req_fragment, s_req_fragment_start, s_req_path, s_req_query_string, s_req_query_string_start, s_req_schema, s_req_schema_slash, s_req_schema_slash_slash, s_req_server, s_req_server_start, s_req_server_with_at, and s_req_spaces_before_url.
Referenced by http_parser_parse_url().
const char* description |
Definition at line 438 of file http_parser_cpp.cpp.
struct { ... } http_strerror_tab[] |
Referenced by http_errno_description(), and http_errno_name().
|
static |
Definition at line 149 of file http_parser_cpp.cpp.
const char* name |
Definition at line 437 of file http_parser_cpp.cpp.
|
static |
Definition at line 236 of file http_parser_cpp.cpp.
|
static |
Definition at line 184 of file http_parser_cpp.cpp.
|
static |
Definition at line 219 of file http_parser_cpp.cpp.