xref: /unit/src/nxt_http_parse.h (revision 16)
1*16Svbart@nginx.com 
2*16Svbart@nginx.com /*
3*16Svbart@nginx.com  * Copyright (C) NGINX, Inc.
4*16Svbart@nginx.com  * Copyright (C) Valentin V. Bartenev
5*16Svbart@nginx.com  */
6*16Svbart@nginx.com 
7*16Svbart@nginx.com #ifndef _NXT_HTTP_PARSER_H_INCLUDED_
8*16Svbart@nginx.com #define _NXT_HTTP_PARSER_H_INCLUDED_
9*16Svbart@nginx.com 
10*16Svbart@nginx.com 
11*16Svbart@nginx.com typedef struct nxt_http_request_parse_s  nxt_http_request_parse_t;
12*16Svbart@nginx.com typedef struct nxt_http_fields_hash_s    nxt_http_fields_hash_t;
13*16Svbart@nginx.com 
14*16Svbart@nginx.com typedef nxt_int_t (*nxt_http_field_handler_t)(void *ctx, nxt_str_t *name,
15*16Svbart@nginx.com                                               nxt_str_t *value, uintptr_t data);
16*16Svbart@nginx.com 
17*16Svbart@nginx.com 
18*16Svbart@nginx.com typedef union {
19*16Svbart@nginx.com    u_char    str[8];
20*16Svbart@nginx.com    uint64_t  ui64;
21*16Svbart@nginx.com } nxt_http_ver_t;
22*16Svbart@nginx.com 
23*16Svbart@nginx.com 
24*16Svbart@nginx.com struct nxt_http_request_parse_s {
25*16Svbart@nginx.com     nxt_int_t               (*handler)(nxt_http_request_parse_t *rp,
26*16Svbart@nginx.com                                        u_char **pos, u_char *end);
27*16Svbart@nginx.com 
28*16Svbart@nginx.com     size_t                  offset;
29*16Svbart@nginx.com 
30*16Svbart@nginx.com     nxt_str_t               method;
31*16Svbart@nginx.com 
32*16Svbart@nginx.com     u_char                  *target_start;
33*16Svbart@nginx.com     u_char                  *target_end;
34*16Svbart@nginx.com     u_char                  *exten_start;
35*16Svbart@nginx.com     u_char                  *args_start;
36*16Svbart@nginx.com 
37*16Svbart@nginx.com     nxt_http_ver_t          version;
38*16Svbart@nginx.com 
39*16Svbart@nginx.com     union {
40*16Svbart@nginx.com         uint8_t             str[32];
41*16Svbart@nginx.com         uint64_t            ui64[4];
42*16Svbart@nginx.com     } field_name_key;
43*16Svbart@nginx.com 
44*16Svbart@nginx.com     nxt_str_t               field_name;
45*16Svbart@nginx.com     nxt_str_t               field_value;
46*16Svbart@nginx.com 
47*16Svbart@nginx.com     nxt_http_fields_hash_t  *hash;
48*16Svbart@nginx.com     void                    *ctx;
49*16Svbart@nginx.com 
50*16Svbart@nginx.com     /* target with "/." */
51*16Svbart@nginx.com     unsigned                complex_target:1;
52*16Svbart@nginx.com     /* target with "%" */
53*16Svbart@nginx.com     unsigned                quoted_target:1;
54*16Svbart@nginx.com     /* target with " " */
55*16Svbart@nginx.com     unsigned                space_in_target:1;
56*16Svbart@nginx.com     /* target with "+" */
57*16Svbart@nginx.com     unsigned                plus_in_target:1;
58*16Svbart@nginx.com };
59*16Svbart@nginx.com 
60*16Svbart@nginx.com 
61*16Svbart@nginx.com typedef struct {
62*16Svbart@nginx.com     nxt_str_t                 name;
63*16Svbart@nginx.com     nxt_http_field_handler_t  handler;
64*16Svbart@nginx.com     uintptr_t                 data;
65*16Svbart@nginx.com } nxt_http_fields_t;
66*16Svbart@nginx.com 
67*16Svbart@nginx.com 
68*16Svbart@nginx.com nxt_int_t nxt_http_parse_request(nxt_http_request_parse_t *rp,
69*16Svbart@nginx.com     nxt_buf_mem_t *b);
70*16Svbart@nginx.com nxt_http_fields_hash_t *nxt_http_fields_hash(nxt_http_fields_t *fields,
71*16Svbart@nginx.com     nxt_mem_pool_t *mp);
72*16Svbart@nginx.com 
73*16Svbart@nginx.com 
74*16Svbart@nginx.com #endif /* _NXT_HTTP_PARSER_H_INCLUDED_ */
75