- separated http_check_method() from http_check_allowed_methods()
[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 /*
22 DUMP:
23 HttpMessage
24 ->toResponseString();
25 ->toRequestString();
26 ->__toString(); ->__sleep(); ->serialize();
27 ->fromString(); __wakeup($message); ->unserialize();
28 ->setStatusCode();
29 ->setHeader(); ->addHeader()...
30 */
31
32 #include "phpstr/phpstr.h"
33 #include "php_http_headers_api.h"
34
35 typedef enum {
36 HTTP_MSG_NONE,
37 HTTP_MSG_REQUEST,
38 HTTP_MSG_RESPONSE
39 } http_message_type;
40
41 typedef struct _http_message http_message;
42
43 struct _http_message {
44 phpstr body;
45 HashTable hdrs;
46 http_message_type type;
47
48 union {
49 struct {
50 float http_version;
51 char *method;
52 char *URI;
53 } request;
54
55 struct {
56 float http_version;
57 int code;
58 } response;
59
60 } info;
61
62 http_message *nested;
63 };
64
65 /* required minimum length of an HTTP message "HTTP/1.1 200\r\n" */
66 #define HTTP_MSG_MIN_SIZE 15
67
68 #define http_message_new() _http_message_init_ex(NULL, 0)
69 #define http_message_init(m) _http_message_init_ex((m), 0)
70 #define http_message_init_ex(m, t) _http_message_init_ex((m), (t))
71 PHP_HTTP_API http_message *_http_message_init_ex(http_message *m, http_message_type t);
72
73 #define http_message_parse(m, l) http_message_parse_ex(NULL, (m), (l))
74 #define http_message_parse_ex(h, m, l) _http_message_parse_ex((h), (m), (l) TSRMLS_CC)
75 PHP_HTTP_API http_message *_http_message_parse_ex(http_message *msg, const char *message, size_t length TSRMLS_DC);
76
77 #define http_message_parse_headers_callback _http_message_parse_headers_callback
78 PHP_HTTP_API void _http_message_parse_headers_callback(void *message, char *http_line, size_t line_length, HashTable **headers TSRMLS_DC);
79
80 #define http_message_tostring(m, s, l) _http_message_tostring((m), (s), (l))
81 PHP_HTTP_API void _http_message_tostring(http_message *msg, char **string, size_t *length);
82 #define http_message_dtor(m) _http_message_dtor((m))
83 PHP_HTTP_API void _http_message_dtor(http_message *message);
84
85 #define http_message_free(m) _http_message_free((m))
86 PHP_HTTP_API void _http_message_free(http_message *message);
87
88 #endif
89
90 /*
91 * Local variables:
92 * tab-width: 4
93 * c-basic-offset: 4
94 * End:
95 * vim600: noet sw=4 ts=4 fdm=marker
96 * vim<600: noet sw=4 ts=4
97 */
98