separate php_http_env_response and implement content encoding
[m6w6/ext-http] / php_http_env.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_ENV_H
16 #define PHP_HTTP_ENV_H
17
18 #include "php_http_message_body.h"
19 #include "php_http_encoding.h"
20 #include "php_http_version.h"
21
22 struct php_http_env_globals {
23 zval *server_var;
24 char *etag_mode;
25
26 struct {
27 time_t time;
28 HashTable *headers;
29 php_http_message_body_t *body;
30 } request;
31 };
32
33 typedef enum php_http_content_encoding {
34 PHP_HTTP_CONTENT_ENCODING_NONE,
35 PHP_HTTP_CONTENT_ENCODING_GZIP
36 } php_http_content_encoding_t;
37
38 typedef enum php_http_range_status {
39 PHP_HTTP_RANGE_NO,
40 PHP_HTTP_RANGE_OK,
41 PHP_HTTP_RANGE_ERR
42 } php_http_range_status_t;
43
44 PHP_HTTP_API php_http_range_status_t php_http_env_get_request_ranges(HashTable *ranges, size_t entity_length TSRMLS_DC);
45 PHP_HTTP_API void php_http_env_get_request_headers(HashTable *headers TSRMLS_DC);
46 PHP_HTTP_API char *php_http_env_get_request_header(const char *name_str, size_t name_len TSRMLS_DC);
47 PHP_HTTP_API int php_http_env_got_request_header(const char *name_str, size_t name_len TSRMLS_DC);
48 PHP_HTTP_API php_http_message_body_t *php_http_env_get_request_body(TSRMLS_D);
49
50 typedef enum php_http_content_disposition {
51 PHP_HTTP_CONTENT_DISPOSITION_NONE,
52 PHP_HTTP_CONTENT_DISPOSITION_INLINE,
53 PHP_HTTP_CONTENT_DISPOSITION_ATTACHMENT
54 } php_http_content_disposition_t;
55
56 typedef enum php_http_cache_status {
57 PHP_HTTP_CACHE_NO,
58 PHP_HTTP_CACHE_HIT,
59 PHP_HTTP_CACHE_MISS
60 } php_http_cache_status_t;
61
62 PHP_HTTP_API long php_http_env_get_response_code(TSRMLS_D);
63 PHP_HTTP_API const char *php_http_env_get_response_status_for_code(unsigned code);
64 PHP_HTTP_API STATUS php_http_env_get_response_headers(HashTable *headers_ht TSRMLS_DC);
65 PHP_HTTP_API char *php_http_env_get_response_header(const char *name_str, size_t name_len TSRMLS_DC);
66 PHP_HTTP_API STATUS php_http_env_set_response_code(long http_code TSRMLS_DC);
67 PHP_HTTP_API STATUS php_http_env_set_response_protocol_version(php_http_version_t *v TSRMLS_DC);
68 PHP_HTTP_API STATUS php_http_env_set_response_header(long http_code, const char *header_str, size_t header_len, zend_bool replace TSRMLS_DC);
69 PHP_HTTP_API STATUS php_http_env_set_response_header_value(long http_code, const char *name_str, size_t name_len, zval *value, zend_bool replace TSRMLS_DC);
70 PHP_HTTP_API STATUS php_http_env_set_response_header_format(long http_code, zend_bool replace TSRMLS_DC, const char *fmt, ...);
71
72 PHP_HTTP_API zval *php_http_env_get_server_var(const char *key_str, size_t key_len, zend_bool check TSRMLS_DC);
73 #define php_http_env_got_server_var(v) (NULL != php_http_env_get_server_var((v), strlen(v), 1 TSRMLS_CC))
74
75 extern zend_class_entry *php_http_env_class_entry;
76 extern zend_function_entry php_http_env_method_entry[];
77
78 PHP_METHOD(HttpEnv, getRequestHeader);
79 PHP_METHOD(HttpEnv, getRequestBody);
80 PHP_METHOD(HttpEnv, getResponseStatusForCode);
81 PHP_METHOD(HttpEnv, getResponseHeader);
82 PHP_METHOD(HttpEnv, getResponseCode);
83 PHP_METHOD(HttpEnv, setResponseHeader);
84 PHP_METHOD(HttpEnv, setResponseCode);
85 PHP_METHOD(HttpEnv, negotiateLanguage);
86 PHP_METHOD(HttpEnv, negotiateCharset);
87 PHP_METHOD(HttpEnv, negotiateContentType);
88 PHP_METHOD(HttpEnv, negotiate);
89 PHP_METHOD(HttpEnv, persistentHandlesStat);
90 PHP_METHOD(HttpEnv, persistentHandlesClean);
91
92 extern zend_class_entry *php_http_env_request_class_entry;
93 extern zend_function_entry php_http_env_request_method_entry[];
94
95 PHP_METHOD(HttpEnvRequest, __construct);
96
97 PHP_MINIT_FUNCTION(http_env);
98 PHP_RINIT_FUNCTION(http_env);
99 PHP_RSHUTDOWN_FUNCTION(http_env);
100
101 #endif
102
103 /*
104 * Local variables:
105 * tab-width: 4
106 * c-basic-offset: 4
107 * End:
108 * vim600: noet sw=4 ts=4 fdm=marker
109 * vim<600: noet sw=4 ts=4
110 */
111