nxt_http_parse.h (112:6f1809436b10) nxt_http_parse.h (417:47366bb40f2c)
1
2/*
3 * Copyright (C) NGINX, Inc.
4 * Copyright (C) Valentin V. Bartenev
5 */
6
7#ifndef _NXT_HTTP_PARSER_H_INCLUDED_
8#define _NXT_HTTP_PARSER_H_INCLUDED_
9
10
11typedef struct nxt_http_request_parse_s nxt_http_request_parse_t;
12typedef struct nxt_http_field_s nxt_http_field_t;
13typedef struct nxt_http_fields_hash_s nxt_http_fields_hash_t;
14
15
16typedef union {
1
2/*
3 * Copyright (C) NGINX, Inc.
4 * Copyright (C) Valentin V. Bartenev
5 */
6
7#ifndef _NXT_HTTP_PARSER_H_INCLUDED_
8#define _NXT_HTTP_PARSER_H_INCLUDED_
9
10
11typedef struct nxt_http_request_parse_s nxt_http_request_parse_t;
12typedef struct nxt_http_field_s nxt_http_field_t;
13typedef struct nxt_http_fields_hash_s nxt_http_fields_hash_t;
14
15
16typedef union {
17 u_char str[8];
18 uint64_t ui64;
17 u_char str[8];
18 uint64_t ui64;
19} nxt_http_ver_t;
20
21
22struct nxt_http_request_parse_s {
23 nxt_int_t (*handler)(nxt_http_request_parse_t *rp,
24 u_char **pos, u_char *end);
25
26 size_t offset;

--- 6 unchanged lines hidden (view full) ---

33 u_char *args_start;
34
35 nxt_str_t path;
36 nxt_str_t args;
37 nxt_str_t exten;
38
39 nxt_http_ver_t version;
40
19} nxt_http_ver_t;
20
21
22struct nxt_http_request_parse_s {
23 nxt_int_t (*handler)(nxt_http_request_parse_t *rp,
24 u_char **pos, u_char *end);
25
26 size_t offset;

--- 6 unchanged lines hidden (view full) ---

33 u_char *args_start;
34
35 nxt_str_t path;
36 nxt_str_t args;
37 nxt_str_t exten;
38
39 nxt_http_ver_t version;
40
41 union {
42 uint8_t str[32];
43 uint64_t ui64[4];
44 } field_key;
41 nxt_list_t *fields;
42 nxt_mp_t *mem_pool;
45
46 nxt_str_t field_name;
47 nxt_str_t field_value;
48
43
44 nxt_str_t field_name;
45 nxt_str_t field_value;
46
49 nxt_http_fields_hash_t *fields_hash;
47 uint32_t field_hash;
50
48
51 nxt_list_t *fields;
52 nxt_mp_t *mem_pool;
53
54 /* target with "/." */
55 unsigned complex_target:1;
56 /* target with "%" */
57 unsigned quoted_target:1;
58 /* target with " " */
59 unsigned space_in_target:1;
60 /* target with "+" */
61 unsigned plus_in_target:1;
62};
63
64
65typedef nxt_int_t (*nxt_http_field_handler_t)(void *ctx,
66 nxt_http_field_t *field,
49 /* target with "/." */
50 unsigned complex_target:1;
51 /* target with "%" */
52 unsigned quoted_target:1;
53 /* target with " " */
54 unsigned space_in_target:1;
55 /* target with "+" */
56 unsigned plus_in_target:1;
57};
58
59
60typedef nxt_int_t (*nxt_http_field_handler_t)(void *ctx,
61 nxt_http_field_t *field,
67 nxt_log_t *log);
62 uintptr_t data);
68
69
70typedef struct {
71 nxt_str_t name;
72 nxt_http_field_handler_t handler;
73 uintptr_t data;
63
64
65typedef struct {
66 nxt_str_t name;
67 nxt_http_field_handler_t handler;
68 uintptr_t data;
74} nxt_http_fields_hash_entry_t;
69} nxt_http_field_proc_t;
75
76
77struct nxt_http_field_s {
70
71
72struct nxt_http_field_s {
78 nxt_str_t name;
79 nxt_str_t value;
80 nxt_http_field_handler_t handler;
81 uintptr_t data;
73 uint16_t hash;
74 uint8_t skip; /* 1 bit */
75 uint8_t name_length;
76 uint32_t value_length;
77 u_char *name;
78 u_char *value;
82};
83
84
79};
80
81
85nxt_inline nxt_int_t
86nxt_http_parse_request_init(nxt_http_request_parse_t *rp, nxt_mp_t *mp)
87{
88 rp->mem_pool = mp;
89
90 rp->fields = nxt_list_create(mp, 8, sizeof(nxt_http_field_t));
91 if (nxt_slow_path(rp->fields == NULL)){
92 return NXT_ERROR;
93 }
94
95 return NXT_OK;
96}
97
98
82nxt_int_t nxt_http_parse_request_init(nxt_http_request_parse_t *rp,
83 nxt_mp_t *mp);
99nxt_int_t nxt_http_parse_request(nxt_http_request_parse_t *rp,
100 nxt_buf_mem_t *b);
101
84nxt_int_t nxt_http_parse_request(nxt_http_request_parse_t *rp,
85 nxt_buf_mem_t *b);
86
102nxt_http_fields_hash_t *nxt_http_fields_hash_create(
103 nxt_http_fields_hash_entry_t *entries, nxt_mp_t *mp);
104nxt_int_t nxt_http_fields_process(nxt_list_t *fields, void *ctx,
105 nxt_log_t *log);
87nxt_int_t nxt_http_fields_hash(nxt_lvlhsh_t *hash, nxt_mp_t *mp,
88 nxt_http_field_proc_t items[], nxt_uint_t count);
89nxt_uint_t nxt_http_fields_hash_collisions(nxt_lvlhsh_t *hash, nxt_mp_t *mp,
90 nxt_http_field_proc_t items[], nxt_uint_t count, nxt_bool_t level);
91nxt_int_t nxt_http_fields_process(nxt_list_t *fields, nxt_lvlhsh_t *hash,
92 void *ctx);
106
107
108#endif /* _NXT_HTTP_PARSER_H_INCLUDED_ */
93
94
95#endif /* _NXT_HTTP_PARSER_H_INCLUDED_ */