- fix request pool issues
[m6w6/ext-http] / php_http_message_api.h
1 /*
2 +----------------------------------------------------------------------+
3 | PECL :: http |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.0 of the PHP license, that |
6 | is bundled with this package in the file LICENSE, and is available |
7 | through the world-wide-web at http://www.php.net/license/3_0.txt. |
8 | If you did not receive a copy of the PHP license and are unable to |
9 | obtain it through the world-wide-web, please send a note to |
10 | license@php.net so we can mail you a copy immediately. |
11 +----------------------------------------------------------------------+
12 | Copyright (c) 2004-2005 Michael Wallner <mike@php.net> |
13 +----------------------------------------------------------------------+
14 */
15
16 /* $Id$ */
17
18 #ifndef PHP_HTTP_MESSAGE_API_H
19 #define PHP_HTTP_MESSAGE_API_H
20
21 #include "phpstr/phpstr.h"
22
23 typedef enum {
24 HTTP_MSG_NONE,
25 HTTP_MSG_REQUEST,
26 HTTP_MSG_RESPONSE
27 } http_message_type;
28
29 typedef struct _http_message http_message;
30
31 struct _http_message {
32 phpstr body;
33 HashTable hdrs;
34 http_message_type type;
35
36 union {
37 struct {
38 float http_version;
39 char *method;
40 char *URI;
41 } request;
42
43 struct {
44 float http_version;
45 int code;
46 } response;
47
48 } info;
49
50 http_message *parent;
51 };
52
53 /* required minimum length of an HTTP message "HTTP/1.1 200\r\n" */
54 #define HTTP_MSG_MIN_SIZE 15
55
56 /* shorthand for type checks */
57 #define HTTP_MSG_TYPE(TYPE, msg) ((msg) && ((msg)->type == HTTP_MSG_ ##TYPE))
58
59 #define http_message_new() _http_message_init_ex(NULL, 0)
60 #define http_message_init(m) _http_message_init_ex((m), 0)
61 #define http_message_init_ex(m, t) _http_message_init_ex((m), (t))
62 PHP_HTTP_API http_message *_http_message_init_ex(http_message *m, http_message_type t);
63
64 #define http_message_set_type(m, t) _http_message_set_type((m), (t))
65 PHP_HTTP_API void _http_message_set_type(http_message *m, http_message_type t);
66
67 #define http_message_parse(m, l) http_message_parse_ex(NULL, (m), (l))
68 #define http_message_parse_ex(h, m, l) _http_message_parse_ex((h), (m), (l) TSRMLS_CC)
69 PHP_HTTP_API http_message *_http_message_parse_ex(http_message *msg, const char *message, size_t length TSRMLS_DC);
70
71 #define http_message_tostring(m, s, l) _http_message_tostring((m), (s), (l))
72 PHP_HTTP_API void _http_message_tostring(http_message *msg, char **string, size_t *length);
73
74 #define http_message_serialize(m, s, l) _http_message_serialize((m), (s), (l))
75 PHP_HTTP_API void _http_message_serialize(http_message *message, char **string, size_t *length);
76
77 #define http_message_send(m) _http_message_send((m) TSRMLS_CC)
78 PHP_HTTP_API STATUS _http_message_send(http_message *message TSRMLS_DC);
79
80 #define http_message_dup(m) _http_message_dup((m) TSRMLS_CC)
81 PHP_HTTP_API http_message *_http_message_dup(http_message *msg TSRMLS_DC);
82
83 #define http_message_dtor(m) _http_message_dtor((m))
84 PHP_HTTP_API void _http_message_dtor(http_message *message);
85
86 #define http_message_free(m) _http_message_free((m))
87 PHP_HTTP_API void _http_message_free(http_message *message);
88
89 #endif
90
91 /*
92 * Local variables:
93 * tab-width: 4
94 * c-basic-offset: 4
95 * End:
96 * vim600: noet sw=4 ts=4 fdm=marker
97 * vim<600: noet sw=4 ts=4
98 */
99