X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_response_object.c;h=85fef4911e7fa8d7c47b598be21fcb539c99d4c0;hp=d21225a3c6f6f8399ca4b2f2db54c8ae0cea0b72;hb=e8608b78db949f6806ee47709aa6799affe69b9e;hpb=13197bcea39d3425d021ee9a03e08ae5381ce296 diff --git a/http_response_object.c b/http_response_object.c index d21225a..85fef49 100644 --- a/http_response_object.c +++ b/http_response_object.c @@ -21,7 +21,10 @@ #endif #include "php.h" -#ifdef ZEND_ENGINE_2 +#include "missing.h" + +/* broken static properties in PHP 5.0 */ +#if defined(ZEND_ENGINE_2) && !defined(WONKY) #include "SAPI.h" #include "php_ini.h" @@ -34,8 +37,6 @@ #include "php_http_send_api.h" #include "php_http_cache_api.h" -#include "missing.h" - ZEND_EXTERN_MODULE_GLOBALS(http); #define GET_STATIC_PROP(n) *GET_STATIC_PROP_EX(http_response_object_ce, n) @@ -142,8 +143,6 @@ HTTP_EMPTY_ARGS(getRequestBody, 0); #define http_response_object_declare_default_properties() _http_response_object_declare_default_properties(TSRMLS_C) static inline void _http_response_object_declare_default_properties(TSRMLS_D); -HashTable http_response_statics; - zend_class_entry *http_response_object_ce; zend_function_entry http_response_object_fe[] = { @@ -290,7 +289,7 @@ PHP_METHOD(HttpResponse, getHeader) array_init(return_value); array_copy(headers, return_value); } else if (SUCCESS == zend_hash_find(Z_ARRVAL_P(headers), name, name_len + 1, (void **) &header)) { - RETURN_ZVAL(*header, ZVAL_PTR_DTOR, 1); + RETURN_ZVAL(*header, 1, 0); } else { RETURN_NULL(); } @@ -335,7 +334,7 @@ PHP_METHOD(HttpResponse, getCache) /* {{{ proto static bool HttpResponse::setGzip(bool gzip) * - * Enable on-thy-fly gzipping of the sent entity. NOT IMPLEMENTED YET. + * Enable on-thy-fly gzipping of the sent entity. */ PHP_METHOD(HttpResponse, setGzip) { @@ -777,7 +776,6 @@ PHP_METHOD(HttpResponse, send) MAKE_STD_ZVAL(the_data); php_ob_get_buffer(the_data TSRMLS_CC); - SET_STATIC_PROP(data, the_data); ZVAL_LONG(GET_STATIC_PROP(mode), SEND_DATA); @@ -786,6 +784,7 @@ PHP_METHOD(HttpResponse, send) UPD_STATIC_PROP(string, eTag, etag); efree(etag); } + zval_ptr_dtor(&the_data); clean_ob = 1; } @@ -811,11 +810,11 @@ PHP_METHOD(HttpResponse, send) zval **data; FOREACH_VAL(*value, data) { - http_send_header_ex(name, strlen(name), Z_STRVAL_PP(data), Z_STRLEN_PP(data), first); + http_send_header_ex(name, strlen(name), Z_STRVAL_PP(data), Z_STRLEN_PP(data), first, NULL); first = 0; } } else { - http_send_header_ex(name, strlen(name), Z_STRVAL_PP(value), Z_STRLEN_PP(value), 1); + http_send_header_ex(name, strlen(name), Z_STRVAL_PP(value), Z_STRLEN_PP(value), 1, NULL); } name = NULL; } @@ -862,7 +861,7 @@ PHP_METHOD(HttpResponse, send) { zval *cd = GET_STATIC_PROP(contentDisposition); if (Z_STRLEN_P(cd)) { - http_send_header_ex("Content-Disposition", lenof("Content-Disposition"), Z_STRVAL_P(cd), Z_STRLEN_P(cd), 1); + http_send_header_ex("Content-Disposition", lenof("Content-Disposition"), Z_STRVAL_P(cd), Z_STRLEN_P(cd), 1, NULL); } } @@ -879,7 +878,7 @@ PHP_METHOD(HttpResponse, send) case SEND_DATA: { zval *zdata = GET_STATIC_PROP(data); - RETURN_SUCCESS(http_send_data(Z_STRVAL_P(zdata), Z_STRLEN_P(zdata))); + RETURN_SUCCESS(http_send_data_ex(Z_STRVAL_P(zdata), Z_STRLEN_P(zdata), 1)); } case SEND_RSRC: @@ -888,12 +887,12 @@ PHP_METHOD(HttpResponse, send) zval *the_stream = GET_STATIC_PROP(stream); the_stream->type = IS_RESOURCE; php_stream_from_zval(the_real_stream, &the_stream); - RETURN_SUCCESS(http_send_stream(the_real_stream)); + RETURN_SUCCESS(http_send_stream_ex(the_real_stream, 0, 1)); } default: { - RETURN_SUCCESS(http_send_file(Z_STRVAL_P(GET_STATIC_PROP(file)))); + RETURN_SUCCESS(http_send_file_ex(Z_STRVAL_P(GET_STATIC_PROP(file)), 1)); } } } @@ -910,28 +909,24 @@ PHP_METHOD(HttpResponse, send) * HttpResponse::setCache(true); * HttpResponse::capture(); * // script follows - * // note that you need to call - * HttpResponse::send(); - * // at the end of the script unless - * // you use PHP-5.1 or greater * ?> * */ PHP_METHOD(HttpResponse, capture) { - zval *do_catch; + zval do_catch; NO_ARGS; - MAKE_STD_ZVAL(do_catch); - ZVAL_LONG(do_catch, 1); + INIT_PZVAL(&do_catch); + ZVAL_LONG(&do_catch, 1); - SET_STATIC_PROP(catch, do_catch); + SET_STATIC_PROP(catch, &do_catch); php_end_ob_buffers(0 TSRMLS_CC); php_start_ob_buffer(NULL, 0, 0 TSRMLS_CC); -#if (PHP_MAJOR_VERSION > 5) || (PHP_MINOR_VERSION > 0) +#ifndef WONKY /* register shutdown function -- messing around with ob and headers only works in PHP-5.1 or greater */ { @@ -953,7 +948,7 @@ PHP_METHOD(HttpResponse, capture) } /* }}} */ -#endif /* ZEND_ENGINE_2 */ +#endif /* ZEND_ENGINE_2 && !WONKY */ /* * Local variables: