2006-01-28 14:03:53 -05:00
|
|
|
#ifndef http11_parser_h
|
|
|
|
#define http11_parser_h
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2006-02-03 00:42:08 -05:00
|
|
|
#if defined(_WIN32)
|
|
|
|
#include <stddef.h>
|
|
|
|
#endif
|
|
|
|
|
2006-01-28 14:03:53 -05:00
|
|
|
typedef void (*element_cb)(void *data, const char *at, size_t length);
|
|
|
|
typedef void (*field_cb)(void *data, const char *field, size_t flen, const char *value, size_t vlen);
|
|
|
|
|
|
|
|
typedef struct http_parser {
|
|
|
|
int cs;
|
2006-05-14 19:41:22 -04:00
|
|
|
size_t body_start;
|
2006-01-28 14:03:53 -05:00
|
|
|
int content_len;
|
|
|
|
size_t nread;
|
2006-05-14 19:41:22 -04:00
|
|
|
size_t mark;
|
|
|
|
size_t field_start;
|
2006-01-28 14:03:53 -05:00
|
|
|
size_t field_len;
|
|
|
|
|
|
|
|
void *data;
|
|
|
|
|
|
|
|
field_cb http_field;
|
|
|
|
element_cb request_method;
|
2006-02-03 00:42:08 -05:00
|
|
|
element_cb request_uri;
|
2006-01-28 14:03:53 -05:00
|
|
|
element_cb query_string;
|
|
|
|
element_cb http_version;
|
2006-03-19 00:18:11 -05:00
|
|
|
element_cb header_done;
|
|
|
|
|
2006-01-28 14:03:53 -05:00
|
|
|
} http_parser;
|
|
|
|
|
|
|
|
int http_parser_init(http_parser *parser);
|
|
|
|
int http_parser_finish(http_parser *parser);
|
2006-05-14 19:41:22 -04:00
|
|
|
size_t http_parser_execute(http_parser *parser, const char *data, size_t len, size_t off);
|
2006-01-28 14:03:53 -05:00
|
|
|
int http_parser_has_error(http_parser *parser);
|
|
|
|
int http_parser_is_finished(http_parser *parser);
|
|
|
|
|
|
|
|
#define http_parser_nread(parser) (parser)->nread
|
|
|
|
|
|
|
|
#endif
|