summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_http_parse.h
blob: e61aa16c6cf18afd4c8f888dc898705fbd2d9738 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

/*
 * Copyright (C) Igor Sysoev
 * Copyright (C) NGINX, Inc.
 */

#ifndef _NXT_HTTP_PARSE_H_INCLUDED_
#define _NXT_HTTP_PARSE_H_INCLUDED_


typedef struct {
    uint8_t                  state;
    uint8_t                  http_version;

    uint32_t                 code;

    u_char                   *start;
    u_char                   *end;
} nxt_http_status_parse_t;


nxt_int_t nxt_http_status_parse(nxt_http_status_parse_t *sp, nxt_buf_mem_t *b);


typedef struct {
    uint32_t                 header_hash;

    uint8_t                  state;
    uint8_t                  underscore;      /* 1 bit */
    uint8_t                  invalid_header;  /* 1 bit */
    uint8_t                  upstream;        /* 1 bit */

    u_char                   *header_start;
    u_char                   *header_end;
    u_char                   *header_name_start;
    u_char                   *header_name_end;
} nxt_http_header_parse_t;


NXT_EXPORT nxt_int_t nxt_http_header_parse(nxt_http_header_parse_t *hp,
    nxt_buf_mem_t *b);


typedef struct {
    u_char                   *start;
    u_char                   *end;
} nxt_http_header_part_t;


typedef struct {
    nxt_array_t              *parts;  /* of nxt_http_header_part_t */
    nxt_mem_pool_t           *mem_pool;

    nxt_http_header_parse_t  parse;
} nxt_http_split_header_parse_t;


nxt_int_t nxt_http_split_header_parse(nxt_http_split_header_parse_t *shp,
    nxt_buf_mem_t *b);


typedef struct {
    u_char                   *pos;
    nxt_mem_pool_t           *mem_pool;

    uint64_t                 chunk_size;

    uint8_t                  state;
    uint8_t                  last;         /* 1 bit */
    uint8_t                  chunk_error;  /* 1 bit */
    uint8_t                  error;        /* 1 bit */
} nxt_http_chunk_parse_t;


NXT_EXPORT nxt_buf_t *nxt_http_chunk_parse(nxt_http_chunk_parse_t *hcp,
    nxt_buf_t *in);


#endif /* _NXT_HTTP_PARSE_H_INCLUDED_ */