xref: /unit/src/nxt_http_parse.h (revision 0:a63ceefd6ab0)
1 
2 /*
3  * Copyright (C) Igor Sysoev
4  * Copyright (C) NGINX, Inc.
5  */
6 
7 #ifndef _NXT_HTTP_PARSE_H_INCLUDED_
8 #define _NXT_HTTP_PARSE_H_INCLUDED_
9 
10 
11 typedef struct {
12     uint8_t                  state;
13     uint8_t                  http_version;
14 
15     uint32_t                 code;
16 
17     u_char                   *start;
18     u_char                   *end;
19 } nxt_http_status_parse_t;
20 
21 
22 nxt_int_t nxt_http_status_parse(nxt_http_status_parse_t *sp, nxt_buf_mem_t *b);
23 
24 
25 typedef struct {
26     uint32_t                 header_hash;
27 
28     uint8_t                  state;
29     uint8_t                  underscore;      /* 1 bit */
30     uint8_t                  invalid_header;  /* 1 bit */
31     uint8_t                  upstream;        /* 1 bit */
32 
33     u_char                   *header_start;
34     u_char                   *header_end;
35     u_char                   *header_name_start;
36     u_char                   *header_name_end;
37 } nxt_http_header_parse_t;
38 
39 
40 NXT_EXPORT nxt_int_t nxt_http_header_parse(nxt_http_header_parse_t *hp,
41     nxt_buf_mem_t *b);
42 
43 
44 typedef struct {
45     u_char                   *start;
46     u_char                   *end;
47 } nxt_http_header_part_t;
48 
49 
50 typedef struct {
51     nxt_array_t              *parts;  /* of nxt_http_header_part_t */
52     nxt_mem_pool_t           *mem_pool;
53 
54     nxt_http_header_parse_t  parse;
55 } nxt_http_split_header_parse_t;
56 
57 
58 nxt_int_t nxt_http_split_header_parse(nxt_http_split_header_parse_t *shp,
59     nxt_buf_mem_t *b);
60 
61 
62 typedef struct {
63     u_char                   *pos;
64     nxt_mem_pool_t           *mem_pool;
65 
66     uint64_t                 chunk_size;
67 
68     uint8_t                  state;
69     uint8_t                  last;         /* 1 bit */
70     uint8_t                  chunk_error;  /* 1 bit */
71     uint8_t                  error;        /* 1 bit */
72 } nxt_http_chunk_parse_t;
73 
74 
75 NXT_EXPORT nxt_buf_t *nxt_http_chunk_parse(nxt_http_chunk_parse_t *hcp,
76     nxt_buf_t *in);
77 
78 
79 #endif /* _NXT_HTTP_PARSE_H_INCLUDED_ */
80