2 +----------------------------------------------------------------------+
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 +----------------------------------------------------------------------+
18 #ifndef PHP_HTTP_MESSAGE_API_H
19 #define PHP_HTTP_MESSAGE_API_H
21 #include "php_http_info_api.h"
22 #include "phpstr/phpstr.h"
26 HTTP_MSG_REQUEST
= IS_HTTP_REQUEST
,
27 HTTP_MSG_RESPONSE
= IS_HTTP_RESPONSE
,
30 typedef struct _http_message http_message
;
32 struct _http_message
{
35 http_message_type type
;
36 struct http_info http
;
40 /* required minimum length of an HTTP message "HTTP/1.1" */
41 #define HTTP_MSG_MIN_SIZE 8
43 /* shorthand for type checks */
44 #define HTTP_MSG_TYPE(TYPE, msg) ((msg) && ((msg)->type == HTTP_MSG_ ##TYPE))
46 #define http_message_new() _http_message_init_ex(NULL, 0)
47 #define http_message_init(m) _http_message_init_ex((m), 0)
48 #define http_message_init_ex(m, t) _http_message_init_ex((m), (t))
49 PHP_HTTP_API http_message
*_http_message_init_ex(http_message
*m
, http_message_type t
);
51 #define http_message_set_type(m, t) _http_message_set_type((m), (t))
52 PHP_HTTP_API
void _http_message_set_type(http_message
*m
, http_message_type t
);
54 #define http_message_header(m, h) _http_message_header_ex((m), (h), sizeof(h))
55 #define http_message_header_ex _http_message_header_ex
56 static inline zval
*_http_message_header_ex(http_message
*msg
, char *key_str
, size_t key_len
)
59 if (SUCCESS
== zend_hash_find(&msg
->hdrs
, key_str
, key_len
, (void **) &header
)) {
65 #define http_message_parse(m, l) http_message_parse_ex(NULL, (m), (l))
66 #define http_message_parse_ex(h, m, l) _http_message_parse_ex((h), (m), (l) TSRMLS_CC)
67 PHP_HTTP_API http_message
*_http_message_parse_ex(http_message
*msg
, const char *message
, size_t length TSRMLS_DC
);
69 #define http_message_tostring(m, s, l) _http_message_tostring((m), (s), (l))
70 PHP_HTTP_API
void _http_message_tostring(http_message
*msg
, char **string
, size_t *length
);
72 #define http_message_serialize(m, s, l) _http_message_serialize((m), (s), (l))
73 PHP_HTTP_API
void _http_message_serialize(http_message
*message
, char **string
, size_t *length
);
75 #define http_message_tostruct_recursive(m, s) _http_message_tostruct_recursive((m), (s) TSRMLS_CC)
76 PHP_HTTP_API
void _http_message_tostruct_recursive(http_message
*msg
, zval
*strct TSRMLS_DC
);
78 #define http_message_send(m) _http_message_send((m) TSRMLS_CC)
79 PHP_HTTP_API STATUS
_http_message_send(http_message
*message TSRMLS_DC
);
81 #define http_message_dup(m) _http_message_dup((m) TSRMLS_CC)
82 PHP_HTTP_API http_message
*_http_message_dup(http_message
*msg TSRMLS_DC
);
84 #define http_message_dtor(m) _http_message_dtor((m))
85 PHP_HTTP_API
void _http_message_dtor(http_message
*message
);
87 #define http_message_free(m) _http_message_free((m))
88 PHP_HTTP_API
void _http_message_free(http_message
**message
);
97 * vim600: noet sw=4 ts=4 fdm=marker
98 * vim<600: noet sw=4 ts=4