view src/lib-http/http-request-parser.h @ 16751:7c7e3aa13de7

lib-http: Implemented limits on request method and target length.
author Stephan Bosch <stephan@rename-it.nl>
date Sun, 15 Sep 2013 03:54:04 +0300
parents 28e5d58e49dc
children e53f5173fa2d
line wrap: on
line source

#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_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) */
};

struct http_request_parser *
http_request_parser_init(struct istream *input,
	const struct http_request_limits *limits) ATTR_NULL(2);
void http_request_parser_deinit(struct http_request_parser **_parser);

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);

#endif