fix problem with dechunk/inflate stream usage
[m6w6/ext-http] / php_http_info.h
1 /*
2 +--------------------------------------------------------------------+
3 | PECL :: http |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2004-2010, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
11 */
12
13 /* $Id: php_http_info_api.h 292841 2009-12-31 08:48:57Z mike $ */
14
15 #ifndef PHP_HTTP_INFO_H
16 #define PHP_HTTP_INFO_H
17
18 #include "php_http_version.h"
19
20 #define PHP_HTTP_INFO_REQUEST_FMT_ARGS(_http_ptr, eol) "%s %s HTTP/%u.%u" eol, \
21 (_http_ptr)->info.request.method?(_http_ptr)->info.request.method:"UNKNOWN", \
22 (_http_ptr)->info.request.url?(_http_ptr)->info.request.url:"/", \
23 (_http_ptr)->version.major||(_http_ptr)->version.major?(_http_ptr)->version.major:1, \
24 (_http_ptr)->version.major||(_http_ptr)->version.minor?(_http_ptr)->version.minor:1
25
26 #define PHP_HTTP_INFO_RESPONSE_FMT_ARGS(_http_ptr, eol) "HTTP/%u.%u %d%s%s" eol, \
27 (_http_ptr)->version.major||(_http_ptr)->version.major?(_http_ptr)->version.major:1, \
28 (_http_ptr)->version.major||(_http_ptr)->version.minor?(_http_ptr)->version.minor:1, \
29 (_http_ptr)->info.response.code?(_http_ptr)->info.response.code:200, \
30 (_http_ptr)->info.response.status&&*(_http_ptr)->info.response.status ? " ":"", \
31 STR_PTR((_http_ptr)->info.response.status)
32
33 typedef struct php_http_info_data {
34 union {
35 /* GET /foo/bar */
36 struct { char *method; char *url; } request;
37 /* 200 Ok */
38 struct { unsigned code; char *status; } response;
39 } info;
40 php_http_version_t version;
41 } php_http_info_data_t;
42
43 typedef enum php_http_info_type {
44 PHP_HTTP_NONE = 0,
45 PHP_HTTP_REQUEST,
46 PHP_HTTP_RESPONSE
47 } php_http_info_type_t;
48
49 #define PHP_HTTP_INFO(ptr) (ptr)->http.info
50 #define PHP_HTTP_INFO_IMPL(_http, _type) \
51 php_http_info_data_t _http; \
52 php_http_info_type_t _type;
53
54 typedef struct php_http_info {
55 PHP_HTTP_INFO_IMPL(http, type)
56 } php_http_info_t;
57
58 typedef zend_bool (*php_http_info_callback_t)(void **callback_data, HashTable **headers, php_http_info_t *info TSRMLS_DC);
59
60 PHP_HTTP_API void php_http_info_default_callback(void **nothing, HashTable **headers, php_http_info_t *info TSRMLS_DC);
61
62 PHP_HTTP_API php_http_info_t *php_http_info_init(php_http_info_t *info TSRMLS_DC);
63 PHP_HTTP_API php_http_info_t *php_http_info_parse(php_http_info_t *info, const char *pre_header TSRMLS_DC);
64 PHP_HTTP_API void php_http_info_dtor(php_http_info_t *info);
65 PHP_HTTP_API void php_http_info_free(php_http_info_t **info);
66
67 #endif
68
69 /*
70 * Local variables:
71 * tab-width: 4
72 * c-basic-offset: 4
73 * End:
74 * vim600: noet sw=4 ts=4 fdm=marker
75 * vim<600: noet sw=4 ts=4
76 */
77