From 445dd5f0580e5073d69d3ef7267671686e18f4e7 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Fri, 22 Jul 2005 20:34:46 +0000 Subject: [PATCH] - add response tests --- config.m4 | 2 ++ http_response_object.c | 5 ++--- tests/HttpResponse_001.phpt | 24 ++++++++++++++++++++++++ tests/HttpResponse_002.phpt | 25 +++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 tests/HttpResponse_001.phpt create mode 100644 tests/HttpResponse_002.phpt diff --git a/config.m4 b/config.m4 index 2f8399c..f54297e 100644 --- a/config.m4 +++ b/config.m4 @@ -79,6 +79,8 @@ dnl ---- PHP_NEW_EXTENSION([http], $PHP_HTTP_SOURCES, [$ext_shared]) PHP_SUBST([HTTP_SHARED_LIBADD]) PHP_ADD_MAKEFILE_FRAGMENT + CFLAGS=" -g -O2 -W -Wchar-subscripts -Wformat=2 -Wno-format-y2k -Wimplicit -Wmissing-braces -Wunused-variable -Wuninitialized -Wstrict-aliasing -Wfloat-equal -Wshadow -Wbad-function-cast -Wpointer-arith -Wsign-compare -Winline" + PHP_SUBST([CFLAGS]) AC_DEFINE([HAVE_HTTP], [1], [Have extended HTTP support]) fi diff --git a/http_response_object.c b/http_response_object.c index 6490238..5303d2d 100644 --- a/http_response_object.c +++ b/http_response_object.c @@ -155,7 +155,6 @@ zend_function_entry http_response_object_fe[] = { {NULL, NULL, NULL} }; -static zend_object_handlers http_response_object_handlers; void _http_response_object_init(INIT_FUNC_ARGS) { @@ -269,7 +268,7 @@ PHP_METHOD(HttpResponse, setCacheControl) #define HTTP_CACHECONTROL_TEMPLATE "%s, must-revalidate, max_age=%ld" - if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &ccontrol, &cc_len, &max_age)) { + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &ccontrol, &cc_len, &max_age)) { RETURN_FALSE; } @@ -649,7 +648,7 @@ PHP_METHOD(HttpResponse, send) /* gzip */ if (Z_LVAL_P(GET_STATIC_PROP(gzip))) { - php_start_ob_buffer_named("ob_gzhandler", 0, 0 TSRMLS_CC); + php_start_ob_buffer_named("ob_gzhandler", 0, 1 TSRMLS_CC); } else { php_start_ob_buffer(NULL, 0, 0 TSRMLS_CC); } diff --git a/tests/HttpResponse_001.phpt b/tests/HttpResponse_001.phpt new file mode 100644 index 0000000..b225f92 --- /dev/null +++ b/tests/HttpResponse_001.phpt @@ -0,0 +1,24 @@ +--TEST-- +HttpResponse - send data with caching headers +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +X-Powered-By: PHP/%s +ETag: "3858f62230ac3c915f300c664312c63f" +Cache-Control: public, must-revalidate, max_age=3600 +Last-Modified: %s, %d %s 20%d %d:%d:%d GMT +Content-Type: %s +Accept-Ranges: bytes + +foobar \ No newline at end of file diff --git a/tests/HttpResponse_002.phpt b/tests/HttpResponse_002.phpt new file mode 100644 index 0000000..6f097b1 --- /dev/null +++ b/tests/HttpResponse_002.phpt @@ -0,0 +1,25 @@ +--TEST-- +HttpResponse - send gzipped file +--SKIPIF-- + +--ENV-- +HTTP_ACCEPT_ENCODING=gzip +--FILE-- + +--EXPECTF-- +X-Powered-By: PHP/%s +Content-Type: %s +Accept-Ranges: bytes +Content-Encoding: gzip +Vary: Accept-Encoding + +%s \ No newline at end of file -- 2.30.2