diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 17:36:47 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 17:36:47 +0000 |
commit | 0441d265f2bb9da249c7abf333f0f771fadb4ab5 (patch) | |
tree | 3f3789daa2f6db22da6e55e92bee0062a7d613fe /src/lib-http/http-request-parser.h | |
parent | Initial commit. (diff) | |
download | dovecot-0441d265f2bb9da249c7abf333f0f771fadb4ab5.tar.xz dovecot-0441d265f2bb9da249c7abf333f0f771fadb4ab5.zip |
Adding upstream version 1:2.3.21+dfsg1.upstream/1%2.3.21+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/lib-http/http-request-parser.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/lib-http/http-request-parser.h b/src/lib-http/http-request-parser.h new file mode 100644 index 0000000..3956062 --- /dev/null +++ b/src/lib-http/http-request-parser.h @@ -0,0 +1,43 @@ +#ifndef HTTP_REQUEST_PARSER_H +#define HTTP_REQUEST_PARSER_H + +#include "http-request.h" + +enum http_request_parse_error { + HTTP_REQUEST_PARSE_ERROR_NONE = 0, /* no error */ + HTTP_REQUEST_PARSE_ERROR_BROKEN_STREAM, /* stream error */ + HTTP_REQUEST_PARSE_ERROR_BROKEN_REQUEST, /* unrecoverable generic error */ + HTTP_REQUEST_PARSE_ERROR_BAD_REQUEST, /* recoverable generic error */ + HTTP_REQUEST_PARSE_ERROR_NOT_IMPLEMENTED, /* used unimplemented feature + (recoverable) */ + HTTP_REQUEST_PARSE_ERROR_EXPECTATION_FAILED, /* unknown item in Expect: + header (recoverable) */ + HTTP_REQUEST_PARSE_ERROR_METHOD_TOO_LONG, /* method too long (fatal) */ + HTTP_REQUEST_PARSE_ERROR_TARGET_TOO_LONG, /* target too long (fatal) */ + HTTP_REQUEST_PARSE_ERROR_PAYLOAD_TOO_LARGE /* payload too large (fatal) */ +}; + +enum http_request_parse_flags { + /* Strictly adhere to the HTTP protocol specification */ + HTTP_REQUEST_PARSE_FLAG_STRICT = BIT(0) +}; + +struct http_request_parser * +http_request_parser_init(struct istream *input, + const struct http_url *default_base_url, + const struct http_request_limits *limits, + enum http_request_parse_flags flags) ATTR_NULL(2); +void http_request_parser_deinit(struct http_request_parser **_parser); + +int http_request_parse_finish_payload( + struct http_request_parser *parser, + enum http_request_parse_error *error_code_r, + const char **error_r); + +int http_request_parse_next(struct http_request_parser *parser, + pool_t pool, struct http_request *request, + enum http_request_parse_error *error_code_r, const char **error_r); + +bool http_request_parser_pending_payload(struct http_request_parser *parser); + +#endif |