* add a real separator vs. a type juggler
[m6w6/ext-http] / php_http_message_parser.h
1
2 #ifndef PHP_HTTP_MESSAGE_PARSER_H
3 #define PHP_HTTP_MESSAGE_PARSER_H
4
5 #include "php_http_header_parser.h"
6 #include "php_http_encoding.h"
7 #include "php_http_message.h"
8
9 typedef enum php_http_message_parser_state {
10 PHP_HTTP_MESSAGE_PARSER_STATE_FAILURE = FAILURE,
11 PHP_HTTP_MESSAGE_PARSER_STATE_START = 0,
12 PHP_HTTP_MESSAGE_PARSER_STATE_HEADER,
13 PHP_HTTP_MESSAGE_PARSER_STATE_HEADER_DONE,
14 PHP_HTTP_MESSAGE_PARSER_STATE_BODY,
15 PHP_HTTP_MESSAGE_PARSER_STATE_BODY_DUMB,
16 PHP_HTTP_MESSAGE_PARSER_STATE_BODY_LENGTH,
17 PHP_HTTP_MESSAGE_PARSER_STATE_BODY_CHUNKED,
18 PHP_HTTP_MESSAGE_PARSER_STATE_BODY_DONE,
19 PHP_HTTP_MESSAGE_PARSER_STATE_DONE
20 } php_http_message_parser_state_t;
21
22 #define PHP_HTTP_MESSAGE_PARSER_CLEANUP 0x1
23 #define PHP_HTTP_MESSAGE_PARSER_DUMB_BODIES 0x2
24 #define PHP_HTTP_MESSAGE_PARSER_EMPTY_REDIRECTS 0x4
25
26 typedef struct php_http_message_parser {
27 php_http_header_parser_t header;
28 zend_stack stack;
29 size_t body_length;
30 php_http_message_t *message;
31 php_http_encoding_stream_t *dechunk;
32 php_http_encoding_stream_t *inflate;
33 #ifdef ZTS
34 void ***ts;
35 #endif
36 } php_http_message_parser_t;
37
38 PHP_HTTP_API php_http_message_parser_t *php_http_message_parser_init(php_http_message_parser_t *parser TSRMLS_DC);
39 PHP_HTTP_API php_http_message_parser_state_t php_http_message_parser_state_push(php_http_message_parser_t *parser, unsigned argc, ...);
40 PHP_HTTP_API php_http_message_parser_state_t php_http_message_parser_state_is(php_http_message_parser_t *parser);
41 PHP_HTTP_API php_http_message_parser_state_t php_http_message_parser_state_pop(php_http_message_parser_t *parser);
42 PHP_HTTP_API void php_http_message_parser_dtor(php_http_message_parser_t *parser);
43 PHP_HTTP_API void php_http_message_parser_free(php_http_message_parser_t **parser);
44 PHP_HTTP_API php_http_message_parser_state_t php_http_message_parser_parse(php_http_message_parser_t *parser, php_http_buffer_t *buffer, unsigned flags, php_http_message_t **message);
45
46 #endif