fix PHP-5.3 compatibility
[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-2014, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
11 */
12
13 #ifndef PHP_HTTP_ENV_H
14 #define PHP_HTTP_ENV_H
15
16 #include "php_http_message_body.h"
17 #include "php_http_version.h"
18
19 struct php_http_env_globals {
20 zval *server_var;
21 char *etag_mode;
22
23 struct {
24 time_t time;
25 HashTable *headers;
26 php_http_message_body_t *body;
27 } request;
28 };
29
30 typedef enum php_http_content_encoding {
31 PHP_HTTP_CONTENT_ENCODING_NONE,
32 PHP_HTTP_CONTENT_ENCODING_GZIP
33 } php_http_content_encoding_t;
34
35 typedef enum php_http_range_status {
36 PHP_HTTP_RANGE_NO,
37 PHP_HTTP_RANGE_OK,
38 PHP_HTTP_RANGE_ERR
39 } php_http_range_status_t;
40
41 PHP_HTTP_API php_http_range_status_t php_http_env_get_request_ranges(HashTable *ranges, size_t entity_length, php_http_message_t *request TSRMLS_DC);
42 PHP_HTTP_API void php_http_env_get_request_headers(HashTable *headers TSRMLS_DC);
43 PHP_HTTP_API char *php_http_env_get_request_header(const char *name_str, size_t name_len, size_t *len, php_http_message_t *request TSRMLS_DC);
44 PHP_HTTP_API int php_http_env_got_request_header(const char *name_str, size_t name_len, php_http_message_t *request TSRMLS_DC);
45 PHP_HTTP_API php_http_message_body_t *php_http_env_get_request_body(TSRMLS_D);
46 PHP_HTTP_API const char *php_http_env_get_request_method(php_http_message_t *request TSRMLS_DC);
47
48 typedef enum php_http_content_disposition {
49 PHP_HTTP_CONTENT_DISPOSITION_NONE,
50 PHP_HTTP_CONTENT_DISPOSITION_INLINE,
51 PHP_HTTP_CONTENT_DISPOSITION_ATTACHMENT
52 } php_http_content_disposition_t;
53
54 typedef enum php_http_cache_status {
55 PHP_HTTP_CACHE_NO,
56 PHP_HTTP_CACHE_HIT,
57 PHP_HTTP_CACHE_MISS
58 } php_http_cache_status_t;
59
60 PHP_HTTP_API long php_http_env_get_response_code(TSRMLS_D);
61 PHP_HTTP_API const char *php_http_env_get_response_status_for_code(unsigned code);
62 PHP_HTTP_API STATUS php_http_env_get_response_headers(HashTable *headers_ht TSRMLS_DC);
63 PHP_HTTP_API char *php_http_env_get_response_header(const char *name_str, size_t name_len TSRMLS_DC);
64 PHP_HTTP_API STATUS php_http_env_set_response_code(long http_code TSRMLS_DC);
65 PHP_HTTP_API STATUS php_http_env_set_response_protocol_version(php_http_version_t *v TSRMLS_DC);
66 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);
67 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);
68 PHP_HTTP_API STATUS php_http_env_set_response_header_format(long http_code, zend_bool replace TSRMLS_DC, const char *fmt, ...);
69 PHP_HTTP_API STATUS php_http_env_set_response_header_va(long http_code, zend_bool replace, const char *fmt, va_list argv TSRMLS_DC);
70
71 PHP_HTTP_API zval *php_http_env_get_server_var(const char *key_str, size_t key_len, zend_bool check TSRMLS_DC);
72 #define php_http_env_got_server_var(v) (NULL != php_http_env_get_server_var((v), strlen(v), 1 TSRMLS_CC))
73 PHP_HTTP_API zval *php_http_env_get_superglobal(const char *key, size_t key_len TSRMLS_DC);
74
75 PHP_HTTP_API zend_class_entry *php_http_env_class_entry;
76 PHP_MINIT_FUNCTION(http_env);
77 PHP_RINIT_FUNCTION(http_env);
78 PHP_RSHUTDOWN_FUNCTION(http_env);
79
80 #endif
81
82 /*
83 * Local variables:
84 * tab-width: 4
85 * c-basic-offset: 4
86 * End:
87 * vim600: noet sw=4 ts=4 fdm=marker
88 * vim<600: noet sw=4 ts=4
89 */
90