You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.2 KiB
53 lines
1.2 KiB
#ifndef __HTTP_REQUEST_PARSER_H__
|
|
#define __HTTP_REQUEST_PARSER_H__
|
|
|
|
#include "class.h"
|
|
#include "http/request.h"
|
|
#include "http/message/queue.h"
|
|
#include "cbuf.h"
|
|
|
|
#define HTTP_REQUEST_PARSER_BUFFER_MAX 8192
|
|
|
|
|
|
/**
|
|
* limits to stop invalid requests from killing
|
|
* the server.
|
|
* If any of these limits is reached the server
|
|
* will send an error message and kill the connection
|
|
* immediate.
|
|
*
|
|
* The given limits include any trailing \r\n
|
|
*/
|
|
#define HTTP_REQUEST_LINE_MAX 8192
|
|
#define HTTP_REQUEST_HEADER_LINE_MAX 2048
|
|
|
|
|
|
typedef enum e_HttpRequestState {
|
|
HTTP_REQUEST_GARBAGE=0,
|
|
HTTP_REQUEST_START,
|
|
HTTP_REQUEST_REQUEST_LINE_DONE,
|
|
HTTP_REQUEST_HEADERS_DONE,
|
|
HTTP_REQUEST_DONE
|
|
} HttpRequestState;
|
|
|
|
|
|
CLASS(HttpRequestParser) {
|
|
Cbuf buffer;
|
|
|
|
HttpMessageQueue request_queue;
|
|
HttpRequest cur_request;
|
|
|
|
HttpRequestState state;
|
|
};
|
|
|
|
ssize_t httpRequestParserRead(HttpRequestParser, int);
|
|
ssize_t httpRequestParserParse(HttpRequestParser, int);
|
|
void httpRequestParserGetBody(HttpRequestParser);
|
|
|
|
ssize_t httpRequestParserGetRequestLine(HttpRequestParser, char *);
|
|
ssize_t httpRequestParserGetHeader(HttpRequestParser, char *);
|
|
void httpRequestParserGetBody(HttpRequestParser);
|
|
|
|
#endif /* __HTTP_REQUEST_PARSER_H__ */
|
|
|
|
// vim: set ts=4 sw=4:
|