2 * Copyright (c) 2005 Zed A. Shaw
3 * You can redistribute it and/or modify it under the same terms as Ruby.
6 #ifndef http11_parser_h
7 #define http11_parser_h
15 enum { MONGREL_CONTENT_LENGTH
16 , MONGREL_CONTENT_TYPE
18 , MONGREL_HTTP_VERSION
19 , MONGREL_QUERY_STRING
20 , MONGREL_REQUEST_PATH
21 , MONGREL_REQUEST_METHOD
25 typedef void (*field_cb
)(void *data
, const char *field
, size_t flen
, const char *value
, size_t vlen
);
26 typedef void (*element_cb
)(void *data
, int type
, const char *at
, size_t length
);
28 typedef struct http_parser
{
32 size_t content_length
;
42 element_cb on_element
;
45 void http_parser_init(http_parser
*parser
);
46 int http_parser_finish(http_parser
*parser
);
47 size_t http_parser_execute(http_parser
*parser
, const char *data
, size_t len
, size_t off
);
48 int http_parser_has_error(http_parser
*parser
);
49 int http_parser_is_finished(http_parser
*parser
);
51 #define http_parser_nread(parser) (parser)->nread