- make the asynchronous behaviour of curl_multi available by socketSend(), socketSele...
[m6w6/ext-http] / http_response_object.c
1 /*
2 +----------------------------------------------------------------------+
3 | PECL :: http |
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 +----------------------------------------------------------------------+
14 */
15
16 /* $Id$ */
17
18
19 #ifdef HAVE_CONFIG_H
20 # include "config.h"
21 #endif
22
23 #include "php.h"
24
25 #include "php_http_std_defs.h"
26 #include "php_http_response_object.h"
27
28 #ifdef ZEND_ENGINE_2
29
30 #include "missing.h"
31
32 #define http_response_object_declare_default_properties() _http_response_object_declare_default_properties(TSRMLS_C)
33 static inline void _http_response_object_declare_default_properties(TSRMLS_D);
34
35 zend_class_entry *http_response_object_ce;
36 zend_function_entry http_response_object_fe[] = {
37 PHP_ME(HttpResponse, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
38
39 PHP_ME(HttpResponse, setETag, NULL, ZEND_ACC_PUBLIC)
40 PHP_ME(HttpResponse, getETag, NULL, ZEND_ACC_PUBLIC)
41
42 PHP_ME(HttpResponse, setContentDisposition, NULL, ZEND_ACC_PUBLIC)
43 PHP_ME(HttpResponse, getContentDisposition, NULL, ZEND_ACC_PUBLIC)
44
45 PHP_ME(HttpResponse, setContentType, NULL, ZEND_ACC_PUBLIC)
46 PHP_ME(HttpResponse, getContentType, NULL, ZEND_ACC_PUBLIC)
47
48 PHP_ME(HttpResponse, setCache, NULL, ZEND_ACC_PUBLIC)
49 PHP_ME(HttpResponse, getCache, NULL, ZEND_ACC_PUBLIC)
50
51 PHP_ME(HttpResponse, setCacheControl, NULL, ZEND_ACC_PUBLIC)
52 PHP_ME(HttpResponse, getCacheControl, NULL, ZEND_ACC_PUBLIC)
53
54 PHP_ME(HttpResponse, setGzip, NULL, ZEND_ACC_PUBLIC)
55 PHP_ME(HttpResponse, getGzip, NULL, ZEND_ACC_PUBLIC)
56
57 PHP_ME(HttpResponse, setThrottleDelay, NULL, ZEND_ACC_PUBLIC)
58 PHP_ME(HttpResponse, getThrottleDelay, NULL, ZEND_ACC_PUBLIC)
59
60 PHP_ME(HttpResponse, setSendBuffersize, NULL, ZEND_ACC_PUBLIC)
61 PHP_ME(HttpResponse, getSendBuffersize, NULL, ZEND_ACC_PUBLIC)
62
63 PHP_ME(HttpResponse, setData, NULL, ZEND_ACC_PUBLIC)
64 PHP_ME(HttpResponse, getData, NULL, ZEND_ACC_PUBLIC)
65
66 PHP_ME(HttpResponse, setFile, NULL, ZEND_ACC_PUBLIC)
67 PHP_ME(HttpResponse, getFile, NULL, ZEND_ACC_PUBLIC)
68
69 PHP_ME(HttpResponse, setStream, NULL, ZEND_ACC_PUBLIC)
70 PHP_ME(HttpResponse, getStream, NULL, ZEND_ACC_PUBLIC)
71
72 PHP_ME(HttpResponse, send, NULL, ZEND_ACC_PUBLIC)
73
74 {NULL, NULL, NULL}
75 };
76 static zend_object_handlers http_response_object_handlers;
77
78 void _http_response_object_init(INIT_FUNC_ARGS)
79 {
80 HTTP_REGISTER_CLASS_EX(HttpResponse, http_response_object, NULL, 0);
81 }
82
83 zend_object_value _http_response_object_new(zend_class_entry *ce TSRMLS_DC)
84 {
85 zend_object_value ov;
86 http_response_object *o;
87
88 o = ecalloc(1, sizeof(http_response_object));
89 o->zo.ce = ce;
90
91 ALLOC_HASHTABLE(OBJ_PROP(o));
92 zend_hash_init(OBJ_PROP(o), 0, NULL, ZVAL_PTR_DTOR, 0);
93 zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
94
95 ov.handle = zend_objects_store_put(o, (zend_objects_store_dtor_t) zend_objects_destroy_object, http_response_object_free, NULL TSRMLS_CC);
96 ov.handlers = &http_response_object_handlers;
97
98 return ov;
99 }
100
101 static inline void _http_response_object_declare_default_properties(TSRMLS_D)
102 {
103 zend_class_entry *ce = http_response_object_ce;
104
105 DCL_PROP(PROTECTED, string, contentType, "application/x-octetstream");
106 DCL_PROP(PROTECTED, string, eTag, "");
107 DCL_PROP(PROTECTED, string, dispoFile, "");
108 DCL_PROP(PROTECTED, string, cacheControl, "public");
109 DCL_PROP(PROTECTED, string, data, "");
110 DCL_PROP(PROTECTED, string, file, "");
111 DCL_PROP(PROTECTED, long, stream, 0);
112 DCL_PROP(PROTECTED, long, lastModified, 0);
113 DCL_PROP(PROTECTED, long, dispoInline, 0);
114 DCL_PROP(PROTECTED, long, cache, 0);
115 DCL_PROP(PROTECTED, long, gzip, 0);
116 DCL_PROP(PROTECTED, long, sendBuffersize, HTTP_SENDBUF_SIZE);
117 DCL_PROP(PROTECTED, double, throttleDelay, 0.0);
118
119 DCL_PROP(PRIVATE, long, raw_cache_header, 0);
120 DCL_PROP(PRIVATE, long, send_mode, -1);
121 }
122
123 void _http_response_object_free(zend_object *object TSRMLS_DC)
124 {
125 http_response_object *o = (http_response_object *) object;
126
127 if (OBJ_PROP(o)) {
128 zend_hash_destroy(OBJ_PROP(o));
129 FREE_HASHTABLE(OBJ_PROP(o));
130 }
131 efree(o);
132 }
133
134 #endif /* ZEND_ENGINE_2 */
135
136 /*
137 * Local variables:
138 * tab-width: 4
139 * c-basic-offset: 4
140 * End:
141 * vim600: noet sw=4 ts=4 fdm=marker
142 * vim<600: noet sw=4 ts=4
143 */
144