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 "phpstr/phpstr.h"
29 typedef struct _http_message http_message
;
31 struct _http_message
{
34 http_message_type type
;
53 /* required minimum length of an HTTP message "HTTP/1.1 200\r\n" */
54 #define HTTP_MSG_MIN_SIZE 15
56 /* shorthand for type checks */
57 #define HTTP_MSG_TYPE(TYPE, msg) ((msg) && ((msg)->type == HTTP_MSG_ ##TYPE))
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
);
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
);
67 #define http_message_header(m, h) _http_message_header_ex((m), (h), sizeof(h))
68 #define http_message_header_ex _http_message_header_ex
69 static inline zval
*_http_message_header_ex(http_message
*msg
, char *key_str
, size_t key_len
)
72 if (SUCCESS
== zend_hash_find(&msg
->hdrs
, key_str
, key_len
, (void **) &header
)) {
78 #define http_message_parse(m, l) http_message_parse_ex(NULL, (m), (l))
79 #define http_message_parse_ex(h, m, l) _http_message_parse_ex((h), (m), (l) TSRMLS_CC)
80 PHP_HTTP_API http_message
*_http_message_parse_ex(http_message
*msg
, const char *message
, size_t length TSRMLS_DC
);
82 #define http_message_tostring(m, s, l) _http_message_tostring((m), (s), (l))
83 PHP_HTTP_API
void _http_message_tostring(http_message
*msg
, char **string
, size_t *length
);
85 #define http_message_serialize(m, s, l) _http_message_serialize((m), (s), (l))
86 PHP_HTTP_API
void _http_message_serialize(http_message
*message
, char **string
, size_t *length
);
88 #define http_message_send(m) _http_message_send((m) TSRMLS_CC)
89 PHP_HTTP_API STATUS
_http_message_send(http_message
*message TSRMLS_DC
);
91 #define http_message_dup(m) _http_message_dup((m) TSRMLS_CC)
92 PHP_HTTP_API http_message
*_http_message_dup(http_message
*msg TSRMLS_DC
);
94 #define http_message_dtor(m) _http_message_dtor((m))
95 PHP_HTTP_API
void _http_message_dtor(http_message
*message
);
97 #define http_message_free(m) _http_message_free((m))
98 PHP_HTTP_API
void _http_message_free(http_message
*message
);
107 * vim600: noet sw=4 ts=4 fdm=marker
108 * vim<600: noet sw=4 ts=4