- ASSOC_PROP(obj, long, "type", msg->type);
- ASSOC_STRINGL(obj, "raw", msg->raw, msg->len)
- ASSOC_STRINGL(obj, "body", PHPSTR_VAL(msg), PHPSTR_LEN(msg));
-
- MAKE_STD_ZVAL(headers);
- array_init(headers);
-
- zend_hash_copy(Z_ARRVAL_P(headers), &msg->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
- ASSOC_PROP(obj, zval, "headers", headers);
-
- switch (msg->type)
- {
- case HTTP_MSG_REQUEST:
- ASSOC_PROP(obj, double, "httpVersion", msg->info.request.http_version);
- ASSOC_PROP(obj, long, "responseStatus", 0);
- ASSOC_STRING(obj, "requestMethod", msg->info.request.method);
- ASSOC_STRING(obj, "requestUri", msg->info.request.URI);
- break;
-
- case HTTP_MSG_RESPONSE:
- ASSOC_PROP(obj, double, "httpVersion", msg->info.response.http_version);
- ASSOC_PROP(obj, long, "responseStatus", msg->info.response.status);
- ASSOC_STRING(obj, "requestMethod", empty_string);
- ASSOC_STRING(obj, "requestUri", empty_string);
- break;
-
- case HTTP_MSG_NONE:
- default:
- ASSOC_PROP(obj, double, "httpVersion", 0.0);
- ASSOC_PROP(obj, long, "responseStatus", 0);
- ASSOC_STRING(obj, "requestMethod", empty_string);
- ASSOC_STRING(obj, "requestUri", empty_string);
- break;
- }
-
- return OBJ_PROP(obj);
-}
-
-#define http_message_global_init() _http_message_global_init(TSRMLS_C)
-static inline void _http_message_global_init(TSRMLS_D)
-{
- http_message_object_handlers.read_property = http_message_object_read_prop;
- http_message_object_handlers.write_property = http_message_object_write_prop;
- http_message_object_handlers.get_properties = http_message_object_get_props;
-}
-
-#define http_message_declare_default_properties(ce) _http_message_declare_default_properties(ce TSRMLS_CC)
-static inline void _http_message_declare_default_properties(zend_class_entry *ce TSRMLS_DC)
-{
- DCL_PROP(PROTECTED, long, type, HTTP_MSG_NONE);
-
- DCL_PROP(PROTECTED, string, raw, "");
- DCL_PROP(PROTECTED, string, body, "");
-
- DCL_PROP(PROTECTED, string, requestMethod, "");
- DCL_PROP(PROTECTED, string, requestUri, "");
- DCL_PROP(PROTECTED, long, responseStatus, 0);
-
- DCL_PROP_N(PROTECTED, httpVersion);
- DCL_PROP_N(PROTECTED, headers);
- DCL_PROP_N(PROTECTED, nestedMessage);
-}
-
-#define http_message_free_object _http_message_free_object
-void _http_message_free_object(zend_object *object TSRMLS_DC)
-{
- http_message_object *o = (http_message_object *) object;
-
- if (OBJ_PROP(o)) {
- zend_hash_destroy(OBJ_PROP(o));
- FREE_HASHTABLE(OBJ_PROP(o));
- }
- if (o->message) {
- http_message_free(o->message);
- }
- efree(o);
-}
-
-#define http_message_new_object _http_message_new_object
-zend_object_value _http_message_new_object(zend_class_entry *ce TSRMLS_DC)
-{
- zend_object_value ov;
- http_message_object *o;
-
- o = ecalloc(1, sizeof(http_message_object));
- o->zo.ce = ce;
- o->message = http_message_new();
-
- ALLOC_HASHTABLE(OBJ_PROP(o));
- zend_hash_init(OBJ_PROP(o), 0, NULL, ZVAL_PTR_DTOR, 0);
-
- ov.handle = zend_objects_store_put(o, (zend_objects_store_dtor_t) zend_objects_destroy_object, http_message_free_object, NULL TSRMLS_CC);
- ov.handlers = &http_message_object_handlers;
-
- return ov;
-}
-
-zend_function_entry http_message_class_methods[] = {
- PHP_ME(HttpMessage, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
- PHP_ME(HttpMessage, __destruct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_DTOR)
- {NULL, NULL, NULL}
-};
-/* }}} */
-
-/* {{{ HttpResponse */
-
-zend_class_entry *http_response_ce;
-static zend_object_handlers http_response_object_handlers;
-
-#define http_response_declare_default_properties(ce) _http_response_declare_default_properties(ce TSRMLS_CC)
-static inline void _http_response_declare_default_properties(zend_class_entry *ce TSRMLS_DC)
-{
- DCL_PROP(PROTECTED, string, contentType, "application/x-octetstream");
- DCL_PROP(PROTECTED, string, eTag, "");
- DCL_PROP(PROTECTED, string, dispoFile, "");
- DCL_PROP(PROTECTED, string, cacheControl, "public");
- DCL_PROP(PROTECTED, string, data, "");
- DCL_PROP(PROTECTED, string, file, "");
- DCL_PROP(PROTECTED, long, stream, 0);
- DCL_PROP(PROTECTED, long, lastModified, 0);
- DCL_PROP(PROTECTED, long, dispoInline, 0);
- DCL_PROP(PROTECTED, long, cache, 0);
- DCL_PROP(PROTECTED, long, gzip, 0);
-
- DCL_PROP(PRIVATE, long, raw_cache_header, 0);
- DCL_PROP(PRIVATE, long, send_mode, -1);
-}
-
-#define http_response_destroy_object _http_response_destroy_object
-void _http_response_destroy_object(void *object, zend_object_handle handle TSRMLS_DC)
-{
- http_response_object *o = object;
- if (OBJ_PROP(o)) {
- zend_hash_destroy(OBJ_PROP(o));
- FREE_HASHTABLE(OBJ_PROP(o));
- }
- efree(o);
-}
-
-#define http_response_new_object _http_response_new_object
-zend_object_value _http_response_new_object(zend_class_entry *ce TSRMLS_DC)
-{
- zend_object_value ov;
- http_response_object *o;
-
- o = ecalloc(1, sizeof(http_response_object));
- o->zo.ce = ce;
-
- ALLOC_HASHTABLE(OBJ_PROP(o));
- zend_hash_init(OBJ_PROP(o), 0, NULL, ZVAL_PTR_DTOR, 0);
- zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
-
- ov.handle = zend_objects_store_put(o, http_response_destroy_object, NULL, NULL TSRMLS_CC);
- ov.handlers = &http_response_object_handlers;
-
- return ov;
-}
-
-zend_function_entry http_response_class_methods[] = {
- PHP_ME(HttpResponse, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
-/* PHP_ME(HttpResponse, __destruct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_DTOR)
-*/
- PHP_ME(HttpResponse, setETag, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpResponse, getETag, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpResponse, setContentDisposition, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpResponse, getContentDisposition, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpResponse, setContentType, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpResponse, getContentType, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpResponse, setCache, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpResponse, getCache, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpResponse, setCacheControl, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpResponse, getCacheControl, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpResponse, setGzip, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpResponse, getGzip, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpResponse, setData, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpResponse, getData, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpResponse, setFile, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpResponse, getFile, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpResponse, setStream, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(HttpResponse, getStream, NULL, ZEND_ACC_PUBLIC)
-
- PHP_ME(HttpResponse, send, NULL, ZEND_ACC_PUBLIC)
-
- {NULL, NULL, NULL}