realease 1.7.1
[m6w6/ext-http] / php_http_info_api.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$ */
14
15 #ifndef PHP_HTTP_INFO_API_H
16 #define PHP_HTTP_INFO_API_H
17
18 #define IS_HTTP_REQUEST 1
19 #define IS_HTTP_RESPONSE 2
20
21 #define HTTP_INFO(ptr) (ptr)->http.info
22
23 #define HTTP_INFO_REQUEST_FMT_ARGS(_http_ptr, _EOL) "%s %s HTTP/%1.1f" _EOL, \
24 (_http_ptr)->info.request.method?(_http_ptr)->info.request.method:"UNKNOWN", \
25 (_http_ptr)->info.request.url?(_http_ptr)->info.request.url:"/", \
26 (_http_ptr)->version>0.0?(_http_ptr)->version:1.1
27
28 #define HTTP_INFO_RESPONSE_FMT_ARGS(_http_ptr, _EOL) "HTTP/%1.1f %d%s%s" _EOL, \
29 (_http_ptr)->version>0.0?(_http_ptr)->version:1.1, \
30 (_http_ptr)->info.response.code?(_http_ptr)->info.response.code:200, \
31 (_http_ptr)->info.response.status&&*(_http_ptr)->info.response.status ? " ":"", \
32 STR_PTR((_http_ptr)->info.response.status)
33
34 typedef struct _http_request_info_t {
35 char *method;
36 char *url;
37 } http_request_info;
38
39 typedef struct _http_response_info_t {
40 int code;
41 char *status;
42 } http_response_info;
43
44 typedef union _http_info_union_t {
45 http_request_info request;
46 http_response_info response;
47 } http_info_union;
48
49 struct http_info {
50 http_info_union info;
51 double version;
52 };
53
54 typedef struct _http_info_t {
55 struct http_info http;
56 int type;
57 } http_info;
58
59 typedef void (*http_info_callback)(void **callback_data, HashTable **headers, http_info *info TSRMLS_DC);
60
61 #define http_info_default_callback _http_info_default_callback
62 PHP_HTTP_API void _http_info_default_callback(void **nothing, HashTable **headers, http_info *info TSRMLS_DC);
63 #define http_info_dtor _http_info_dtor
64 PHP_HTTP_API void _http_info_dtor(http_info *info);
65 #define http_info_parse(p, i) _http_info_parse_ex((p), (i), 1 TSRMLS_CC)
66 #define http_info_parse_ex(p, i, s) _http_info_parse_ex((p), (i), (s) TSRMLS_CC)
67 PHP_HTTP_API STATUS _http_info_parse_ex(const char *pre_header, http_info *info , zend_bool silent TSRMLS_DC);
68
69 #endif
70
71 /*
72 * Local variables:
73 * tab-width: 4
74 * c-basic-offset: 4
75 * End:
76 * vim600: noet sw=4 ts=4 fdm=marker
77 * vim<600: noet sw=4 ts=4
78 */
79