xref: /unit/src/nxt_http_parse.h (revision 422)
116Svbart@nginx.com 
216Svbart@nginx.com /*
316Svbart@nginx.com  * Copyright (C) NGINX, Inc.
416Svbart@nginx.com  * Copyright (C) Valentin V. Bartenev
516Svbart@nginx.com  */
616Svbart@nginx.com 
716Svbart@nginx.com #ifndef _NXT_HTTP_PARSER_H_INCLUDED_
816Svbart@nginx.com #define _NXT_HTTP_PARSER_H_INCLUDED_
916Svbart@nginx.com 
1016Svbart@nginx.com 
1116Svbart@nginx.com typedef struct nxt_http_request_parse_s  nxt_http_request_parse_t;
1267Svbart@nginx.com typedef struct nxt_http_field_s          nxt_http_field_t;
1316Svbart@nginx.com typedef struct nxt_http_fields_hash_s    nxt_http_fields_hash_t;
1416Svbart@nginx.com 
1560Svbart@nginx.com 
1660Svbart@nginx.com typedef union {
17417Svbart@nginx.com     u_char                    str[8];
18417Svbart@nginx.com     uint64_t                  ui64;
1960Svbart@nginx.com } nxt_http_ver_t;
2016Svbart@nginx.com 
2116Svbart@nginx.com 
2216Svbart@nginx.com struct nxt_http_request_parse_s {
2367Svbart@nginx.com     nxt_int_t                 (*handler)(nxt_http_request_parse_t *rp,
2467Svbart@nginx.com                                          u_char **pos, u_char *end);
2567Svbart@nginx.com 
2667Svbart@nginx.com     size_t                    offset;
2716Svbart@nginx.com 
2867Svbart@nginx.com     nxt_str_t                 method;
2916Svbart@nginx.com 
3067Svbart@nginx.com     u_char                    *target_start;
3167Svbart@nginx.com     u_char                    *target_end;
3267Svbart@nginx.com     u_char                    *exten_start;
3367Svbart@nginx.com     u_char                    *args_start;
3416Svbart@nginx.com 
35112Smax.romanov@nginx.com     nxt_str_t                 path;
36112Smax.romanov@nginx.com     nxt_str_t                 args;
37112Smax.romanov@nginx.com     nxt_str_t                 exten;
38112Smax.romanov@nginx.com 
3967Svbart@nginx.com     nxt_http_ver_t            version;
4067Svbart@nginx.com 
41417Svbart@nginx.com     nxt_list_t                *fields;
42417Svbart@nginx.com     nxt_mp_t                  *mem_pool;
4316Svbart@nginx.com 
4467Svbart@nginx.com     nxt_str_t                 field_name;
4567Svbart@nginx.com     nxt_str_t                 field_value;
4616Svbart@nginx.com 
47417Svbart@nginx.com     uint32_t                  field_hash;
4816Svbart@nginx.com 
4916Svbart@nginx.com     /* target with "/." */
5067Svbart@nginx.com     unsigned                  complex_target:1;
5116Svbart@nginx.com     /* target with "%" */
5267Svbart@nginx.com     unsigned                  quoted_target:1;
5316Svbart@nginx.com     /* target with " " */
5467Svbart@nginx.com     unsigned                  space_in_target:1;
5516Svbart@nginx.com     /* target with "+" */
5667Svbart@nginx.com     unsigned                  plus_in_target:1;
5716Svbart@nginx.com };
5816Svbart@nginx.com 
5916Svbart@nginx.com 
6060Svbart@nginx.com typedef nxt_int_t (*nxt_http_field_handler_t)(void *ctx,
6160Svbart@nginx.com                                               nxt_http_field_t *field,
62417Svbart@nginx.com                                               uintptr_t data);
6360Svbart@nginx.com 
6460Svbart@nginx.com 
6516Svbart@nginx.com typedef struct {
6616Svbart@nginx.com     nxt_str_t                 name;
6716Svbart@nginx.com     nxt_http_field_handler_t  handler;
6816Svbart@nginx.com     uintptr_t                 data;
69417Svbart@nginx.com } nxt_http_field_proc_t;
7060Svbart@nginx.com 
7160Svbart@nginx.com 
7267Svbart@nginx.com struct nxt_http_field_s {
73417Svbart@nginx.com     uint16_t                  hash;
74417Svbart@nginx.com     uint8_t                   skip;             /* 1 bit */
75417Svbart@nginx.com     uint8_t                   name_length;
76417Svbart@nginx.com     uint32_t                  value_length;
77417Svbart@nginx.com     u_char                    *name;
78417Svbart@nginx.com     u_char                    *value;
7967Svbart@nginx.com };
8067Svbart@nginx.com 
8167Svbart@nginx.com 
82417Svbart@nginx.com nxt_int_t nxt_http_parse_request_init(nxt_http_request_parse_t *rp,
83417Svbart@nginx.com     nxt_mp_t *mp);
8416Svbart@nginx.com nxt_int_t nxt_http_parse_request(nxt_http_request_parse_t *rp,
8516Svbart@nginx.com     nxt_buf_mem_t *b);
86*422Svbart@nginx.com nxt_int_t nxt_http_parse_fields(nxt_http_request_parse_t *rp,
87*422Svbart@nginx.com     nxt_buf_mem_t *b);
8860Svbart@nginx.com 
89417Svbart@nginx.com nxt_int_t nxt_http_fields_hash(nxt_lvlhsh_t *hash, nxt_mp_t *mp,
90417Svbart@nginx.com     nxt_http_field_proc_t items[], nxt_uint_t count);
91417Svbart@nginx.com nxt_uint_t nxt_http_fields_hash_collisions(nxt_lvlhsh_t *hash, nxt_mp_t *mp,
92417Svbart@nginx.com     nxt_http_field_proc_t items[], nxt_uint_t count, nxt_bool_t level);
93417Svbart@nginx.com nxt_int_t nxt_http_fields_process(nxt_list_t *fields, nxt_lvlhsh_t *hash,
94417Svbart@nginx.com     void *ctx);
9516Svbart@nginx.com 
9616Svbart@nginx.com 
9716Svbart@nginx.com #endif /* _NXT_HTTP_PARSER_H_INCLUDED_ */
98