/** * Copyright (c) 2005 Zed A. Shaw * You can redistribute it and/or modify it under the same terms as Ruby. */ #ifndef http11_parser_h #define http11_parser_h #include #if defined(_WIN32) #include #endif 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 httpclient_parser { int cs; size_t body_start; int content_len; size_t nread; size_t mark; size_t field_start; size_t field_len; void *data; field_cb http_field; element_cb reason_phrase; element_cb status_code; element_cb chunk_size; element_cb http_version; element_cb header_done; } httpclient_parser; int httpclient_parser_init(httpclient_parser *parser); int httpclient_parser_finish(httpclient_parser *parser); size_t httpclient_parser_execute(httpclient_parser *parser, const char *data, size_t len, size_t off); int httpclient_parser_has_error(httpclient_parser *parser); int httpclient_parser_is_finished(httpclient_parser *parser); #define httpclient_parser_nread(parser) (parser)->nread #endif