annotate src/lib-http/http-parser.h @ 22656:1789bf2a1e01

director: Make sure HOST-RESET-USERS isn't used with max_moving_users=0 The reset command would just hang in that case. doveadm would never have sent this, so this is just an extra sanity check.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sun, 05 Nov 2017 23:51:56 +0200
parents 2121057f994b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15394
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
1 #ifndef HTTP_PARSER_H
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
2 #define HTTP_PARSER_H
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
3
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
4 /*
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
5 * Character definitions
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
6 */
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
7
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
8 extern const unsigned char _http_token_char_mask;
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
9 extern const unsigned char _http_value_char_mask;
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
10 extern const unsigned char _http_text_char_mask;
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
11 extern const unsigned char _http_qdtext_char_mask;
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
12 extern const unsigned char _http_ctext_char_mask;
17771
2121057f994b lib-http: Implemented HTTP auth (RFC 7235).
Stephan Bosch <stephan@rename-it.nl>
parents: 17549
diff changeset
13 extern const unsigned char _http_token68_char_mask;
15394
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
14
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
15 extern const unsigned char _http_char_lookup[256];
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
16
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
17 static inline bool http_char_is_token(unsigned char ch) {
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
18 return (_http_char_lookup[ch] & _http_token_char_mask) != 0;
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
19 }
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
20
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
21 static inline bool http_char_is_value(unsigned char ch) {
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
22 return (_http_char_lookup[ch] & _http_value_char_mask) != 0;
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
23 }
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
24
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
25 static inline bool http_char_is_text(unsigned char ch) {
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
26 return (_http_char_lookup[ch] & _http_text_char_mask) != 0;
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
27 }
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
28
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
29 static inline bool http_char_is_qdtext(unsigned char ch) {
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
30 return (_http_char_lookup[ch] & _http_qdtext_char_mask) != 0;
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
31 }
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
32
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
33 static inline bool http_char_is_ctext(unsigned char ch) {
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
34 return (_http_char_lookup[ch] & _http_ctext_char_mask) != 0;
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
35 }
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
36
17771
2121057f994b lib-http: Implemented HTTP auth (RFC 7235).
Stephan Bosch <stephan@rename-it.nl>
parents: 17549
diff changeset
37 static inline bool http_char_is_token68(unsigned char ch) {
2121057f994b lib-http: Implemented HTTP auth (RFC 7235).
Stephan Bosch <stephan@rename-it.nl>
parents: 17549
diff changeset
38 return (_http_char_lookup[ch] & _http_token68_char_mask) != 0;
2121057f994b lib-http: Implemented HTTP auth (RFC 7235).
Stephan Bosch <stephan@rename-it.nl>
parents: 17549
diff changeset
39 }
2121057f994b lib-http: Implemented HTTP auth (RFC 7235).
Stephan Bosch <stephan@rename-it.nl>
parents: 17549
diff changeset
40
15394
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
41 /*
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
42 * HTTP value parsing
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
43 */
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
44
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
45 struct http_parser {
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
46 const unsigned char *begin, *cur, *end;
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
47 };
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
48
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
49 void http_parser_init(struct http_parser *parser,
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
50 const unsigned char *data, size_t size);
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
51
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
52 void http_parse_ows(struct http_parser *parser);
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
53
17771
2121057f994b lib-http: Implemented HTTP auth (RFC 7235).
Stephan Bosch <stephan@rename-it.nl>
parents: 17549
diff changeset
54 int http_parser_skip_token(struct http_parser *parser);
15394
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
55 int http_parse_token(struct http_parser *parser, const char **token_r);
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
56 int http_parse_token_list_next(struct http_parser *parser,
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
57 const char **token_r);
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
58
16742
1404dbde402c lib-http: Added support for parsing HTTP word syntax, which includes quoted-string.
Stephan Bosch <stephan@rename-it.nl>
parents: 15394
diff changeset
59 int http_parse_quoted_string(struct http_parser *parser, const char **str_r);
17549
9511372c7c18 lib-http: Updated comments to RFC7230/RFC7231.
Stephan Bosch <stephan@rename-it.nl>
parents: 16742
diff changeset
60 int http_parse_token_or_qstring(struct http_parser *parser,
9511372c7c18 lib-http: Updated comments to RFC7230/RFC7231.
Stephan Bosch <stephan@rename-it.nl>
parents: 16742
diff changeset
61 const char **word_r);
16742
1404dbde402c lib-http: Added support for parsing HTTP word syntax, which includes quoted-string.
Stephan Bosch <stephan@rename-it.nl>
parents: 15394
diff changeset
62
15394
107c8b2c9594 lib-http: Added initial HTTP client implementation.
Stephan Bosch <stephan@rename-it.nl>
parents:
diff changeset
63 #endif