- add response tests
authorMichael Wallner <mike@php.net>
Fri, 22 Jul 2005 20:34:46 +0000 (20:34 +0000)
committerMichael Wallner <mike@php.net>
Fri, 22 Jul 2005 20:34:46 +0000 (20:34 +0000)
config.m4
http_response_object.c
tests/HttpResponse_001.phpt [new file with mode: 0644]
tests/HttpResponse_002.phpt [new file with mode: 0644]

index 2f8399cfd387c0bb65d6de838a15d54d7147bdf2..f54297e20d715a38e2025cb4192072e4125c5c61 100644 (file)
--- 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
 
index 6490238b2e966cbbfad9fb4ee4f0e44ddf818d3d..5303d2d0ed76bd1c934b2428dad2ad8a5d3dc652 100644 (file)
@@ -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 (file)
index 0000000..b225f92
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+HttpResponse - send data with caching headers
+--SKIPIF--
+<?php 
+include 'skip.inc';
+checkver(5);
+checkcgi();
+?>
+--FILE--
+<?php
+HttpResponse::setCache(true);
+HttpResponse::setCacheControl('public', 3600);
+HttpResponse::setData('foobar');
+HttpResponse::send();
+?>
+--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 (file)
index 0000000..6f097b1
--- /dev/null
@@ -0,0 +1,25 @@
+--TEST--
+HttpResponse - send gzipped file
+--SKIPIF--
+<?php 
+include 'skip.inc';
+checkver(5);
+checkcgi();
+checkext('zlib');
+?>
+--ENV--
+HTTP_ACCEPT_ENCODING=gzip
+--FILE--
+<?php
+HttpResponse::setGzip(true);
+HttpResponse::setFile(__FILE__);
+HttpResponse::send();
+?>
+--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