nxt_http_parse.h (1:fdc027c56872) nxt_http_parse.h (16:c382e548cbb6)
1
2/*
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
3 * Copyright (C) NGINX, Inc.
4 * Copyright (C) Valentin V. Bartenev
5 */
6
5 */
6
7#ifndef _NXT_HTTP_PARSE_H_INCLUDED_
8#define _NXT_HTTP_PARSE_H_INCLUDED_
7#ifndef _NXT_HTTP_PARSER_H_INCLUDED_
8#define _NXT_HTTP_PARSER_H_INCLUDED_
9
10
9
10
11typedef struct {
12 uint8_t state;
13 uint8_t http_version;
11typedef struct nxt_http_request_parse_s nxt_http_request_parse_t;
12typedef struct nxt_http_fields_hash_s nxt_http_fields_hash_t;
14
13
15 uint32_t code;
14typedef nxt_int_t (*nxt_http_field_handler_t)(void *ctx, nxt_str_t *name,
15 nxt_str_t *value, uintptr_t data);
16
16
17 u_char *start;
18 u_char *end;
19} nxt_http_status_parse_t;
20
17
18typedef union {
19 u_char str[8];
20 uint64_t ui64;
21} nxt_http_ver_t;
21
22
22nxt_int_t nxt_http_status_parse(nxt_http_status_parse_t *sp, nxt_buf_mem_t *b);
23
23
24struct nxt_http_request_parse_s {
25 nxt_int_t (*handler)(nxt_http_request_parse_t *rp,
26 u_char **pos, u_char *end);
24
27
25typedef struct {
26 uint32_t header_hash;
28 size_t offset;
27
29
28 uint8_t state;
29 uint8_t underscore; /* 1 bit */
30 uint8_t invalid_header; /* 1 bit */
31 uint8_t upstream; /* 1 bit */
30 nxt_str_t method;
32
31
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;
32 u_char *target_start;
33 u_char *target_end;
34 u_char *exten_start;
35 u_char *args_start;
38
36
37 nxt_http_ver_t version;
39
38
40NXT_EXPORT nxt_int_t nxt_http_header_parse(nxt_http_header_parse_t *hp,
41 nxt_buf_mem_t *b);
39 union {
40 uint8_t str[32];
41 uint64_t ui64[4];
42 } field_name_key;
42
43
44 nxt_str_t field_name;
45 nxt_str_t field_value;
43
46
44typedef struct {
45 u_char *start;
46 u_char *end;
47} nxt_http_header_part_t;
47 nxt_http_fields_hash_t *hash;
48 void *ctx;
48
49
50 /* target with "/." */
51 unsigned complex_target:1;
52 /* target with "%" */
53 unsigned quoted_target:1;
54 /* target with " " */
55 unsigned space_in_target:1;
56 /* target with "+" */
57 unsigned plus_in_target:1;
58};
49
59
60
50typedef struct {
61typedef struct {
51 nxt_array_t *parts; /* of nxt_http_header_part_t */
52 nxt_mem_pool_t *mem_pool;
62 nxt_str_t name;
63 nxt_http_field_handler_t handler;
64 uintptr_t data;
65} nxt_http_fields_t;
53
66
54 nxt_http_header_parse_t parse;
55} nxt_http_split_header_parse_t;
56
67
57
58nxt_int_t nxt_http_split_header_parse(nxt_http_split_header_parse_t *shp,
68nxt_int_t nxt_http_parse_request(nxt_http_request_parse_t *rp,
59 nxt_buf_mem_t *b);
69 nxt_buf_mem_t *b);
70nxt_http_fields_hash_t *nxt_http_fields_hash(nxt_http_fields_t *fields,
71 nxt_mem_pool_t *mp);
60
61
72
73
62typedef 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
75NXT_EXPORT nxt_buf_t *nxt_http_chunk_parse(nxt_task_t *task,
76 nxt_http_chunk_parse_t *hcp, nxt_buf_t *in);
77
78
79#endif /* _NXT_HTTP_PARSE_H_INCLUDED_ */
74#endif /* _NXT_HTTP_PARSER_H_INCLUDED_ */