197 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
198 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
199 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
200 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
201 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
202 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
203 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
204 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
732 p->
error = htparse_error_none;
735 for (i = 0; i < len; i++)
742 log_debug(
"[%p] data[%zu] = %c (%x)", p, i, isprint(ch) ? ch :
' ', ch);
751 if (ch ==
CR || ch ==
LF)
756 if ((ch <
'A' || ch >
'Z') && ch !=
'_')
758 p->
error = htparse_error_inval_reqline;
760 log_debug(
"s_start invalid fist char '%c'", ch);
768 p->
error = htparse_error_none;
769 p->
method = htp_method_UNKNOWN;
784 res = hook_on_msg_begin_run(p, hooks);
790 }
else if (p->
type == htp_type_response && ch ==
'H') {
793 log_debug(
"not type of request or response?");
796 p->
error = htparse_error_inval_reqline;
802 p->
error = htparse_error_user;
815 res = hook_method_run(p, hooks, p->
buf, p->
buf_idx);
822 p->
error = htparse_error_user;
828 if ((ch <
'A' || ch >
'Z') && ch !=
'_')
830 p->
error = htparse_error_inval_method;
842 log_debug(
"[%p] s_spaces_before_uri", p);
851 if (p->
method == htp_method_CONNECT)
866 p->
error = htparse_error_inval_reqline;
894 c = (
unsigned char)(ch | 0x20);
896 if (c >=
'a' && c <=
'z') {
905 p->
error = htparse_error_inval_reqline;
915 c = (
unsigned char)(ch | 0x20);
917 if (c >=
'a' && c <=
'z') {
924 p->
scheme = htp_scheme_unknown;
930 p->
scheme = htp_scheme_ftp;
936 p->
scheme = htp_scheme_nfs;
944 p->
scheme = htp_scheme_http;
951 p->
scheme = htp_scheme_https;
957 res = hook_scheme_run(p, hooks,
966 p->
error = htparse_error_user;
972 p->
error = htparse_error_inval_schema;
987 p->
error = htparse_error_inval_schema;
992 log_debug(
"[%p] s_schema_slash_slash", p);
1002 p->
error = htparse_error_inval_schema;
1021 res = hook_host_run(p, hooks,
1027 p->
error = htparse_error_user;
1051 p->
error = htparse_error_inval_state;
1068 p->
error = htparse_error_inval_schema;
1074 p->
error = htparse_error_user;
1080 c = (
unsigned char)(ch | 0x20);
1082 if ((c >=
'a' && c <=
'f')
1083 || (ch >=
'0' && ch <=
'9')
1095 p->
error = htparse_error_user;
1104 p->
error = htparse_error_inval_schema;
1109 if (ch >=
'0' && ch <=
'9') {
1124 p->
error = htparse_error_inval_state;
1140 p->
error = htparse_error_inval_reqline;
1149 p->
error = htparse_error_user;
1155 log_debug(
"[%p] s_after_slash_in_uri", p);
1159 if (
usual[ch >> 5] & (1 << (ch & 0x1f)))
1172 int r2 = hook_uri_run(p, hooks, p->
buf, p->
buf_idx);
1218 p->
error = htparse_error_user;
1231 if (
usual[ch >> 5] & (1 << (ch & 0x1f))) {
1255 r2 = hook_uri_run(p, hooks, p->
buf, p->
buf_idx);
1282 res = hook_path_run(p, hooks,
1299 p->
error = htparse_error_user;
1311 if (
usual[ch >> 5] & (1 << (ch & 0x1f))) {
1376 p->
error = htparse_error_user;
1403 p->
error = htparse_error_inval_proto;
1416 p->
error = htparse_error_inval_proto;
1426 p->
error = htparse_error_inval_proto;
1436 p->
error = htparse_error_inval_proto;
1446 p->
error = htparse_error_inval_proto;
1451 if (ch <
'1' || ch >
'9')
1453 p->
error = htparse_error_inval_ver;
1457 p->
major = ch -
'0';
1467 if (ch <
'0' || ch >
'9')
1469 p->
error = htparse_error_inval_ver;
1476 if (ch <
'0' || ch >
'9')
1478 p->
error = htparse_error_inval_ver;
1482 p->
minor = ch -
'0';
1491 }
else if (p->
type == htp_type_response)
1502 p->
error = htparse_error_inval_reqline;
1503 log_debug(
"[s_minor_digit] LF without CR!");
1508 if (ch <
'0' || ch >
'9')
1510 p->
error = htparse_error_inval_ver;
1529 if (ch <
'0' || ch >
'9')
1531 p->
error = htparse_error_status;
1555 p->
error = htparse_error_generic;
1582 p->
error = htparse_error_inval_ver;
1592 res = hook_on_hdrs_begin_run(p, hooks);
1596 p->
error = htparse_error_user;
1607 res = hook_on_hdrs_begin_run(p, hooks);
1610 p->
error = htparse_error_user;
1615 p->
error = htparse_error_inval_reqline;
1659 res = hook_hdr_key_run(p, hooks, p->
buf, p->
buf_idx);
1666 if (!strcasecmp(p->
buf,
"host"))
1672 if (!strcasecmp(p->
buf,
"connection"))
1678 if (!strcasecmp(p->
buf,
"content-type"))
1684 if (!strcasecmp(p->
buf,
"content-length"))
1690 if (!strcasecmp(p->
buf,
"proxy-connection"))
1696 if (!strcasecmp(p->
buf,
"transfer-encoding"))
1708 p->
error = htparse_error_user;
1738 log_debug(
"[%p] s_hdrline_hdr_space_before_val", p);
1762 p->
error = htparse_error_inval_hdr;
1781 if (hook_hostname_run(p, hooks, p->
buf, p->
buf_idx))
1784 p->
error = htparse_error_user;
1797 p->
error = htparse_error_too_big;
1803 switch (p->
buf[0]) {
1815 A_case = (p->
buf[5] ==
'A') ?
'A' :
'a';
1816 S_buf = (
const char *)(p->
buf + 1);
1819 'e',
'e',
'p',
'-', A_case,
'l',
'i',
'v',
'e'))
1831 C_case = (p->
buf[0] ==
'C') ?
'C' :
'c';
1832 S_buf = (
const char *)p->
buf;
1834 if (
_str5cmp(S_buf, C_case,
'l',
'o',
's',
'e'))
1847 switch (p->
buf[0]) {
1857 S_buf = (
const char *)(p->
buf + 1);
1859 if (
_str6cmp(S_buf,
'h',
'u',
'n',
'k',
'e',
'd'))
1874 switch (p->
buf[0]) {
1879 S_buf = (
const char *)(p->
buf + 1);
1881 if (
_str8cmp(S_buf,
'u',
'l',
't',
'i',
'p',
'a',
'r',
't'))
1903 p->
error = htparse_error_inval_hdr;
1920 log_debug(
"[%p] s_hdrline_hdr_almost_done", p);
1927 res = hook_on_msg_complete_run(p, hooks);
1935 p->
error = htparse_error_inval_hdr;
1941 p->
error = htparse_error_user;
1947 log_debug(
"[%p] s_hdrline_hdr_done", p);
1951 res = hook_hdr_val_run(p, hooks, p->
buf, p->
buf_idx);
1956 p->
error = htparse_error_user;
1963 p->
error = htparse_error_inval_hdr;
1972 res = hook_hdr_val_run(p, hooks, p->
buf, p->
buf_idx);
1980 p->
error = htparse_error_user;
1988 log_debug(
"[%p] s_hdrline_almost_done", p);
1992 res = hook_on_hdrs_complete_run(p, hooks);
1996 p->
error = htparse_error_user;
2004 res = hook_on_msg_complete_run(p, hooks);
2014 res = hook_on_msg_complete_run(p, hooks);
2022 p->
error = htparse_error_user;
2028 p->
error = htparse_error_inval_hdr;
2034 p->
error = htparse_error_user;
2046 res = hook_on_msg_complete_run(p, hooks);
2058 res = hook_on_msg_complete_run(p, hooks);
2064 p->
error = htparse_error_user;
2070 c =
unhex[(
unsigned char)ch];
2074 p->
error = htparse_error_inval_chunk_sz;
2088 c =
unhex[(
unsigned char)ch];
2092 p->
error = htparse_error_inval_chunk_sz;
2103 p->
error = htparse_error_inval_chunk_sz;
2111 res = hook_on_chunks_complete_run(p, hooks);
2116 res = hook_on_new_chunk_run(p, hooks);
2123 p->
error = htparse_error_user;
2132 const char * pp = &data[i];
2133 const char * pe = (
const char *)(data + len);
2138 res = hook_body_run(p, hooks, pp, to_read);
2153 p->
error = htparse_error_user;
2162 p->
error = htparse_error_inval_chunk;
2172 p->
error = htparse_error_inval_chunk;
2179 if (hook_on_chunk_complete_run(p, hooks))
2181 p->
error = htparse_error_user;
2191 const char * pp = &data[i];
2192 const char * pe = (
const char *)(data + len);
2196 res = hook_body_run(p, hooks, pp, to_read);
2203 p->
error = htparse_error_user;
2208 res = hook_on_msg_complete_run(p, hooks);
2214 p->
error = htparse_error_user;
2222 log_debug(
"[%p] This is a silly state....", p);
2223 p->
error = htparse_error_inval_state;