From: Michael Wallner Date: Wed, 22 Nov 2006 10:50:11 +0000 (+0000) Subject: - improve response performance X-Git-Tag: RELEASE_1_4_0RC1~16 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=6991b7214b3647780be00917c069db46d46b0484;p=m6w6%2Fext-http - improve response performance . flag streams non-buffered . bypass sapi input filter . flush explicitly only if throttling is used - fix tests --- diff --git a/http.c b/http.c index cbc38eb..05f448f 100644 --- a/http.c +++ b/http.c @@ -206,6 +206,10 @@ static inline void _http_globals_free(zend_http_globals *G TSRMLS_DC) } STR_SET(G->send.content_type, NULL); STR_SET(G->send.unquoted_etag, NULL); + if (G->server_var) { + zval_ptr_dtor(&G->server_var); + G->server_var = NULL; + } } /* }}} */ diff --git a/http_api.c b/http_api.c index b77dd19..4e304af 100644 --- a/http_api.c +++ b/http_api.c @@ -267,11 +267,26 @@ STATUS _http_check_method_ex(const char *method, const char *methods) /* {{{ zval *http_get_server_var_ex(char *, size_t) */ PHP_HTTP_API zval *_http_get_server_var_ex(const char *key, size_t key_size, zend_bool check TSRMLS_DC) { - zval **hsv; - zval **var; + zval **hsv, **var; + char *env; + + /* if available, this is a lot faster than accessing $_SERVER */ + if (sapi_module.getenv) { + if ((!(env = sapi_module.getenv((char *) key, key_size TSRMLS_CC))) || (check && !*env)) { + return NULL; + } + if (HTTP_G->server_var) { + zval_ptr_dtor(&HTTP_G->server_var); + } + MAKE_STD_ZVAL(HTTP_G->server_var); + ZVAL_STRING(HTTP_G->server_var, env, 1); + return HTTP_G->server_var; + } + #ifdef ZEND_ENGINE_2 zend_is_auto_global("_SERVER", lenof("_SERVER") TSRMLS_CC); #endif + if ((SUCCESS != zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void *) &hsv)) || (Z_TYPE_PP(hsv) != IS_ARRAY)) { return NULL; } diff --git a/http_send_api.c b/http_send_api.c index 1fe1d4d..ed92028 100644 --- a/http_send_api.c +++ b/http_send_api.c @@ -27,19 +27,20 @@ #include "php_http_headers_api.h" #include "php_http_send_api.h" +/* {{{ http_flush() */ #define http_flush(d, l) _http_flush(NULL, (d), (l) TSRMLS_CC) -/* {{{ static inline void http_flush() */ static inline void _http_flush(void *nothing, const char *data, size_t data_len TSRMLS_DC) { PHPWRITE(data, data_len); - php_end_ob_buffer(1, 1 TSRMLS_CC); - sapi_flush(TSRMLS_C); - -#if 0 - fprintf(stderr, "Flushing after writing %u bytes\n", (uint) data_len); -#endif - + /* we really only need to flush when throttling is enabled, + because we push the data as fast as possible anyway if not */ if (HTTP_G->send.throttle_delay >= HTTP_DIFFSEC) { + if (OG(ob_nesting_level)) { + php_end_ob_buffer(1, 1 TSRMLS_CC); + } + if (!OG(implicit_flush)) { + sapi_flush(TSRMLS_C); + } http_sleep(HTTP_G->send.throttle_delay); } } @@ -58,6 +59,8 @@ static inline void _http_send_response_start(void **buffer, size_t content_lengt HTTP_DEFLATE_TYPE_GZIP : HTTP_DEFLATE_TYPE_ZLIB); #endif } + /* flush headers */ + sapi_flush(TSRMLS_C); } /* }}} */ @@ -93,19 +96,20 @@ static inline void _http_send_response_data_plain(void **buffer, const char *dat #define http_send_response_data_fetch(b, d, l, m, s, e) _http_send_response_data_fetch((b), (d), (l), (m), (s), (e) TSRMLS_CC) static inline void _http_send_response_data_fetch(void **buffer, const void *data, size_t data_len, http_send_mode mode, size_t begin, size_t end TSRMLS_DC) { - char *buf; - long got, len = end - begin; + long bsz, got, len = end - begin; + + if (!(bsz = HTTP_G->send.buffer_size)) { + bsz = HTTP_SENDBUF_SIZE; + } switch (mode) { - case SEND_RSRC: - { + case SEND_RSRC: { php_stream *s = (php_stream *) data; - if (SUCCESS == php_stream_seek(s, begin, SEEK_SET)) { - buf = emalloc(HTTP_SENDBUF_SIZE); + char *buf = emalloc(bsz); while (len > 0) { - got = php_stream_read(s, buf, MIN(len, HTTP_SENDBUF_SIZE)); + got = php_stream_read(s, buf, MIN(len, bsz)); http_send_response_data_plain(buffer, buf, got); len -= got; } @@ -114,20 +118,16 @@ static inline void _http_send_response_data_fetch(void **buffer, const void *dat } break; } - - case SEND_DATA: - { - buf = (char *) data + begin; - + case SEND_DATA: { + const char *buf = data + begin; while (len > 0) { - got = MIN(len, HTTP_SENDBUF_SIZE); + got = MIN(len, bsz); http_send_response_data_plain(buffer, buf, got); len -= got; buf += got; } break; } - EMPTY_SWITCH_DEFAULT_CASE(); } } @@ -507,6 +507,7 @@ PHP_HTTP_API STATUS _http_send_stream_ex(php_stream *file, zend_bool close_strea { STATUS status; php_stream_statbuf ssb; + int orig_flags; if ((!file) || php_stream_stat(file, &ssb)) { char *defct = sapi_get_default_content_type(TSRMLS_C); @@ -522,8 +523,11 @@ PHP_HTTP_API STATUS _http_send_stream_ex(php_stream *file, zend_bool close_strea return FAILURE; } + orig_flags = file->flags; + file->flags |= PHP_STREAM_FLAG_NO_BUFFER; status = http_send_ex(file, ssb.sb.st_size, SEND_RSRC, no_cache); - + file->flags = orig_flags; + if (close_stream) { php_stream_close(file); } diff --git a/package2.xml b/package2.xml index 684b39d..b49b7dd 100644 --- a/package2.xml +++ b/package2.xml @@ -28,7 +28,7 @@ support. Parallel requests are available for PHP 5 and greater. mike@php.net yes - 2006-11-05 + 2006-11-22 1.4.0dev 1.4.0 @@ -39,6 +39,7 @@ support. Parallel requests are available for PHP 5 and greater. BSD, revised - - diff --git a/php_http.h b/php_http.h index 61fd4c8..f77755a 100644 --- a/php_http.h +++ b/php_http.h @@ -144,6 +144,7 @@ ZEND_BEGIN_MODULE_GLOBALS(http) zend_bool force_exit; zend_bool read_post_data; + zval *server_var; ZEND_END_MODULE_GLOBALS(http) diff --git a/php_http_std_defs.h b/php_http_std_defs.h index f851983..0a80180 100644 --- a/php_http_std_defs.h +++ b/php_http_std_defs.h @@ -111,7 +111,7 @@ typedef int STATUS; #define HTTP_URL_ARGSEP "&" /* send buffer size */ -#define HTTP_SENDBUF_SIZE 40960 +#define HTTP_SENDBUF_SIZE 8000 /*40960*/ /* CURL buffer size */ #define HTTP_CURLBUF_SIZE 16384 diff --git a/tests/HttpResponse_004.phpt b/tests/HttpResponse_004.phpt index 4e6d30c..ffe26c9 100644 --- a/tests/HttpResponse_004.phpt +++ b/tests/HttpResponse_004.phpt @@ -7,10 +7,11 @@ checkcgi(); checkmin(5.1); skipif(!http_support(HTTP_SUPPORT_ENCODINGS), "need zlib support"); ?> +--ENV-- +HTTP_IF_NONE_MATCH="900150983cd24fb0d6963f7d28e17f72" +HTTP_ACCEPT_ENCODING=gzip --FILE-- +--ENV-- +HTTP_HOST=www.example.com --FILE-- +--ENV-- +HTTP_ACCEPT=application/xml, application/xhtml+xml, text/html ; q = .8 +HTTP_ACCEPT_LANGUAGE=de-AT,de-DE;q=0.8,en-GB;q=0.3,en-US;q=0.2 +HTTP_ACCEPT_CHARSET=ISO-8859-1,utf-8;q=0.7,*;q=0.7 --FILE-- +--ENV-- +HTTP_RANGE=bytes=-5 --FILE-- @@ -19,4 +20,4 @@ Accept-Ranges: bytes Content-Range: bytes 5995-5999/6000 Content-Length: 5 -23abc \ No newline at end of file +23abc diff --git a/tests/send_data_002.phpt b/tests/send_data_002.phpt index 4e8f07b..af7e866 100644 --- a/tests/send_data_002.phpt +++ b/tests/send_data_002.phpt @@ -5,9 +5,10 @@ http_send_data() NUM-NUM range include 'skip.inc'; checkcgi(); ?> +--ENV-- +HTTP_RANGE=bytes=5-6 --FILE-- @@ -19,4 +20,4 @@ Accept-Ranges: bytes Content-Range: bytes 5-6/6000 Content-Length: 2 -c1 \ No newline at end of file +c1 diff --git a/tests/send_data_003.phpt b/tests/send_data_003.phpt index 87663fc..c13ec80 100644 --- a/tests/send_data_003.phpt +++ b/tests/send_data_003.phpt @@ -5,9 +5,10 @@ http_send_data() NUM-NIL range include 'skip.inc'; checkcgi(); ?> +--ENV-- +HTTP_RANGE=bytes=5981- --FILE-- @@ -19,4 +20,4 @@ Accept-Ranges: bytes Content-Range: bytes 5981-5999/6000 Content-Length: 19 -c123abc123abc123abc \ No newline at end of file +c123abc123abc123abc diff --git a/tests/send_data_005.phpt b/tests/send_data_005.phpt index 286c7e9..28cbb78 100644 --- a/tests/send_data_005.phpt +++ b/tests/send_data_005.phpt @@ -5,12 +5,13 @@ http_send_data() oversized range include 'skip.inc'; checkcgi(); ?> +--ENV-- +HTTP_RANGE=bytes=5990-6000 --FILE-- --EXPECTF-- Status: 416 -%s \ No newline at end of file +%s diff --git a/tests/send_failed_precond_001.phpt b/tests/send_failed_precond_001.phpt index 6424ecb..dd394e7 100644 --- a/tests/send_failed_precond_001.phpt +++ b/tests/send_failed_precond_001.phpt @@ -6,10 +6,11 @@ include 'skip.inc'; checkcgi(); checkver(5.1); ?> +--ENV-- +HTTP_RANGE=bytes=0-1 +HTTP_IF_UNMODIFIED_SINCE=Thu, 01 Jan 1970 00:16:40 GMT --FILE-- diff --git a/tests/send_file_005.phpt b/tests/send_file_005.phpt index b5287a3..d6705ea 100644 --- a/tests/send_file_005.phpt +++ b/tests/send_file_005.phpt @@ -5,9 +5,10 @@ http_send_file() multiple ranges include 'skip.inc'; checkcgi(); ?> +--ENV-- +HTTP_RANGE=bytes=0-3, 4-5,9-11 --FILE-- diff --git a/tests/send_file_009.phpt b/tests/send_file_009.phpt index 3215b03..bc157a9 100644 --- a/tests/send_file_009.phpt +++ b/tests/send_file_009.phpt @@ -6,9 +6,10 @@ include 'skip.inc'; checkcgi(); checkmin(5.1); ?> +--ENV-- +HTTP_RANGE=bytes=5-9 --FILE-- --EXPECTF-- diff --git a/tests/send_file_010.phpt b/tests/send_file_010.phpt index 8ee6eac..20b853a 100644 --- a/tests/send_file_010.phpt +++ b/tests/send_file_010.phpt @@ -6,9 +6,10 @@ include 'skip.inc'; checkcgi(); checkmin(5.1); ?> +--ENV-- +HTTP_RANGE=bytes=-9 --FILE-- --EXPECTF-- diff --git a/tests/send_file_011.phpt b/tests/send_file_011.phpt index 1012da4..df6ec60 100644 --- a/tests/send_file_011.phpt +++ b/tests/send_file_011.phpt @@ -6,9 +6,10 @@ include 'skip.inc'; checkcgi(); checkmin(5.1); ?> +--ENV-- +HTTP_RANGE=bytes=1000- --FILE-- --EXPECTF-- diff --git a/tests/send_file_013.phpt b/tests/send_file_013.phpt index 1315488..e97a091 100644 --- a/tests/send_file_013.phpt +++ b/tests/send_file_013.phpt @@ -6,9 +6,10 @@ include 'skip.inc'; checkcgi(); checkmin(5.1); ?> +--ENV-- +HTTP_RANGE=bytes=-1111 --FILE-- --EXPECTF-- diff --git a/tests/send_ifrange_001.phpt b/tests/send_ifrange_001.phpt index 4328226..9b36971 100644 --- a/tests/send_ifrange_001.phpt +++ b/tests/send_ifrange_001.phpt @@ -5,10 +5,11 @@ http_send() If-Range include 'skip.inc'; checkcgi(); ?> +--ENV-- +HTTP_RANGE=bytes=0-1 +HTTP_IF_RANGE="abc" --FILE-- diff --git a/tests/send_ifrange_003.phpt b/tests/send_ifrange_003.phpt index 902130f..746d9c7 100644 --- a/tests/send_ifrange_003.phpt +++ b/tests/send_ifrange_003.phpt @@ -5,10 +5,11 @@ http_send() If-Range include 'skip.inc'; checkcgi(); ?> +--ENV-- +HTTP_RANGE=bytes=0-1 +HTTP_IF_RANGE="abcd" --FILE-- diff --git a/tests/ut_HttpMessage.phpt b/tests/ut_HttpMessage.phpt deleted file mode 100644 index dd36680..0000000 --- a/tests/ut_HttpMessage.phpt +++ /dev/null @@ -1,272 +0,0 @@ ---TEST-- -PHPUnit HttpMessage ---SKIPIF-- - ---FILE-- -emptyMessage = new HttpMessage; - $this->responseMessage = new HttpMessage("HTTP/1.1 302 Found\r\nLocation: /foo\r\nHTTP/1.1 200 Ok\r\nServer: Funky/1.0\r\n\r\nHi there!"); - $this->requestMessage = new HttpMessage("GET /foo HTTP/1.1\r\nHost: example.com\r\nContent-type: text/plain\r\nContent-length: 10\r\n\r\nHi there!\n"); - } - - function test___construct() - { - $this->assertTrue(new HttpMessage instanceof HttpMessage, "new HttpMessage instanceof HttpMessage"); - } - - function test_getBody() - { - $this->assertEquals('', $this->emptyMessage->getBody()); - $this->assertEquals('Hi there!', $this->responseMessage->getBody()); - $this->assertEquals("Hi there!\n", $this->requestMessage->getBody()); - } - - function test_setBody() - { - $this->emptyMessage->setBody('New Body 1'); - $this->responseMessage->setBody('New Body 2'); - $this->requestMessage->setBody('New Body 3'); - $this->assertEquals('New Body 2', $this->responseMessage->getBody()); - $this->assertEquals('New Body 1', $this->emptyMessage->getBody()); - $this->assertEquals('New Body 3', $this->requestMessage->getBody()); - } - - function test_getHeaders() - { - $this->assertEquals(array(), $this->emptyMessage->getHeaders()); - $this->assertEquals(array('Server' => 'Funky/1.0'), $this->responseMessage->getHeaders()); - $this->assertEquals(array('Host' => 'example.com', 'Content-Type' => 'text/plain', 'Content-Length' => '10'), $this->requestMessage->getHeaders()); - } - - function test_setHeaders() - { - $this->emptyMessage->setHeaders(array('Foo' => 'Bar')); - $this->responseMessage->setHeaders(array()); - $this->requestMessage->setHeaders(array('Host' => 'www.example.com')); - $this->assertEquals(array('Foo' => 'Bar'), $this->emptyMessage->getHeaders()); - $this->assertEquals(array(), $this->responseMessage->getHeaders()); - $this->assertEquals(array('Host' => 'www.example.com'), $this->requestMessage->getHeaders()); - } - - function test_addHeaders() - { - $this->emptyMessage->addHeaders(array('Foo' => 'Bar')); - $this->responseMessage->addHeaders(array('Date' => 'today')); - $this->requestMessage->addHeaders(array('Host' => 'www.example.com')); - $this->assertEquals(array('Foo' => 'Bar'), $this->emptyMessage->getHeaders()); - $this->assertEquals(array('Server' => 'Funky/1.0', 'Date' => 'today'), $this->responseMessage->getHeaders()); - $this->assertEquals(array('Host' => 'www.example.com', 'Content-Type' => 'text/plain', 'Content-Length' => '10'), $this->requestMessage->getHeaders()); - $this->emptyMessage->addHeaders(array('Foo' => 'Baz'), true); - $this->assertEquals(array('Foo' => array('Bar', 'Baz')), $this->emptyMessage->getHeaders()); - } - - function test_getType() - { - $this->assertEquals(HTTP_MSG_NONE, $this->emptyMessage->getType()); - $this->assertEquals(HTTP_MSG_RESPONSE, $this->responseMessage->getType()); - $this->assertEquals(HTTP_MSG_REQUEST, $this->requestMessage->getType()); - } - - function test_setType() - { - $this->emptyMessage->setType(HTTP_MSG_RESPONSE); - $this->responseMessage->setType(HTTP_MSG_REQUEST); - $this->requestMessage->setType(HTTP_MSG_NONE); - $this->assertEquals(HTTP_MSG_RESPONSE, $this->emptyMessage->getType()); - $this->assertEquals(HTTP_MSG_REQUEST, $this->responseMessage->getType()); - $this->assertEquals(HTTP_MSG_NONE, $this->requestMessage->getType()); - } - - function test_getResponseCode() - { - $this->assertFalse($this->emptyMessage->getResponseCode()); - $this->assertEquals(200, $this->responseMessage->getResponseCode()); - $this->assertFalse($this->requestMessage->getResponseCode()); - } - - function test_setResponseCode() - { - $this->assertFalse($this->emptyMessage->setResponseCode(301)); - $this->assertTrue($this->responseMessage->setResponseCode(301)); - $this->assertFalse($this->requestMessage->setResponseCode(301)); - $this->assertFalse($this->emptyMessage->getResponseCode()); - $this->assertEquals(301, $this->responseMessage->getResponseCode()); - $this->assertFalse($this->requestMessage->getResponseCode()); - } - - function test_getRequestMethod() - { - $this->assertFalse($this->emptyMessage->getRequestMethod()); - $this->assertFalse($this->responseMessage->getRequestMethod()); - $this->assertEquals('GET', $this->requestMessage->getRequestMethod()); - } - - function test_setRequestMethod() - { - $this->assertFalse($this->emptyMessage->setRequestMethod('POST')); - $this->assertFalse($this->responseMessage->setRequestMethod('POST')); - $this->assertTrue($this->requestMessage->setRequestMethod('POST')); - $this->assertFalse($this->emptyMessage->getRequestMethod()); - $this->assertFalse($this->responseMessage->getRequestMethod()); - $this->assertEquals('POST', $this->requestMessage->getRequestMethod()); - } - - function test_getRequestUrl() - { - $this->assertFalse($this->emptyMessage->getRequestUrl()); - $this->assertFalse($this->responseMessage->getRequestUrl()); - $this->assertEquals('/foo', $this->requestMessage->getRequestUrl()); - } - - function test_setRequestUrl() - { - $this->assertFalse($this->emptyMessage->setRequestUrl('/bla')); - $this->assertFalse($this->responseMessage->setRequestUrl('/bla')); - $this->assertTrue($this->requestMessage->setRequestUrl('/bla')); - $this->assertFalse($this->emptyMessage->getRequestUrl()); - $this->assertFalse($this->responseMessage->getRequestUrl()); - $this->assertEquals('/bla', $this->requestMessage->getRequestUrl()); - } - - function test_getHttpVersion() - { - $this->assertEquals('0.0', $this->emptyMessage->getHttpVersion()); - $this->assertEquals('1.1', $this->responseMessage->getHttpVersion()); - $this->assertEquals('1.1', $this->requestMessage->getHttpVersion()); - } - - function test_setHttpVersion() - { - $this->assertTrue($this->emptyMessage->setHttpVersion(1.0)); - $this->assertTrue($this->responseMessage->setHttpVersion(1.0)); - $this->assertTrue($this->requestMessage->setHttpVersion(1.0)); - $this->assertEquals('1.0', $this->emptyMessage->getHttpVersion()); - $this->assertEquals('1.0', $this->responseMessage->getHttpVersion()); - $this->assertEquals('1.0', $this->requestMessage->getHttpVersion()); - } - - function test_getParentMessage() - { - $this->assertTrue($this->responseMessage->getParentMessage() instanceOf HttpMessage); - try { - $this->requestMessage->getParentMessage(); - $this->assertTrue(false, "\$this->requestMessage->getParentMessage() did not throw an exception"); - } catch (HttpRuntimeException $ex) { - } - } - - function test_send() - { - } - - function test_toString() - { - $this->assertEquals('', $this->emptyMessage->toString()); - $this->assertEquals("HTTP/1.1 200 Ok\r\nServer: Funky/1.0\r\n\r\nHi there!\r\n", $this->responseMessage->toString()); - $this->assertEquals("GET /foo HTTP/1.1\r\nHost: example.com\r\nContent-Type: text/plain\r\nContent-Length: 10\r\n\r\nHi there!\n\r\n", $this->requestMessage->toString()); - } - - function test_count() - { - if (5.1 <= (float)PHP_VERSION) { - $this->assertEquals(1, count($this->emptyMessage)); - $this->assertEquals(2, count($this->responseMessage)); - $this->assertEquals(1, count($this->requestMessage)); - } else { - $this->assertEquals(1, $this->emptyMessage->count()); - $this->assertEquals(2, $this->responseMessage->count()); - $this->assertEquals(1, $this->requestMessage->count()); - } - } - - function test_serialize() - { - } - - function test_unserialize() - { - } - - function test___toString() - { - ob_start(); - echo $this->responseMessage; - $this->assertEquals("HTTP/1.1 200 Ok\r\nServer: Funky/1.0\r\n\r\nHi there!\r\n", ob_get_clean()); - } - - function test_fromString() - { - $msg = HttpMessage::fromString("HTTP/1.1 200 Ok\r\nServer: Funky/1.0\r\n\r\nHi there!"); - $this->assertTrue($msg instanceOf HttpMessage); - $this->assertEquals(HTTP_MSG_RESPONSE, $msg->getType()); - $this->assertEquals("Hi there!", $msg->getBody()); - } -} - -$s = new PHPUnit2_Framework_TestSuite('HttpMessageTest'); -$p = new PHPUnit2_TextUI_ResultPrinter(); -$p->printResult($s->run(), 0); - -echo "Done\n"; -?> ---EXPECTF-- -%sTEST - -Notice: HttpMessage::getResponseCode(): HttpMessage is not of type HTTP_MSG_RESPONSE in %sut_HttpMessage.php on line %d - -Notice: HttpMessage::getResponseCode(): HttpMessage is not of type HTTP_MSG_RESPONSE in %sut_HttpMessage.php on line %d - -Notice: HttpMessage::setResponseCode(): HttpMessage is not of type HTTP_MSG_RESPONSE in %sut_HttpMessage.php on line %d - -Notice: HttpMessage::setResponseCode(): HttpMessage is not of type HTTP_MSG_RESPONSE in %sut_HttpMessage.php on line %d - -Notice: HttpMessage::getResponseCode(): HttpMessage is not of type HTTP_MSG_RESPONSE in %sut_HttpMessage.php on line %d - -Notice: HttpMessage::getResponseCode(): HttpMessage is not of type HTTP_MSG_RESPONSE in %sut_HttpMessage.php on line %d - -Notice: HttpMessage::getRequestMethod(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d - -Notice: HttpMessage::getRequestMethod(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d - -Notice: HttpMessage::setRequestMethod(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d - -Notice: HttpMessage::setRequestMethod(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d - -Notice: HttpMessage::getRequestMethod(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d - -Notice: HttpMessage::getRequestMethod(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d - -Notice: HttpMessage::getRequestUrl(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d - -Notice: HttpMessage::getRequestUrl(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d - -Notice: HttpMessage::setRequestUrl(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d - -Notice: HttpMessage::setRequestUrl(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d - -Notice: HttpMessage::getRequestUrl(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d - -Notice: HttpMessage::getRequestUrl(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d - - -Time: 0 - -OK (24 tests) -Done diff --git a/tests/ut_HttpRequest.phpt b/tests/ut_HttpRequest.phpt deleted file mode 100644 index 3b69c2a..0000000 --- a/tests/ut_HttpRequest.phpt +++ /dev/null @@ -1,250 +0,0 @@ ---TEST-- -PHPUnit HttpRequest ---SKIPIF-- - ---FILE-- -printResult($s->run(), 0); - -echo "Done\n"; -?> ---EXPECTF-- -%sTEST - - -Time: 0 - -OK (53 tests) -Done diff --git a/tests/ut_HttpRequestPool.phpt b/tests/ut_HttpRequestPool.phpt deleted file mode 100644 index 1d82a63..0000000 --- a/tests/ut_HttpRequestPool.phpt +++ /dev/null @@ -1,102 +0,0 @@ ---TEST-- -PHPUnit HttpRequestPool ---SKIPIF-- - ---FILE-- -printResult($s->run(), 0); - -echo "Done\n"; -?> ---EXPECTF-- -%sTEST - - -Time: 0 - -OK (16 tests) -Done diff --git a/tests/ut_HttpUtil.phpt b/tests/ut_HttpUtil.phpt deleted file mode 100644 index 6bf6e2e..0000000 --- a/tests/ut_HttpUtil.phpt +++ /dev/null @@ -1,124 +0,0 @@ ---TEST-- -PHPUnit HttpUtil ---SKIPIF-- - ---FILE-- -assertEquals('Thu, 01 Jan 1970 00:00:01 GMT', HttpUtil::date(1)); - } - - function test_buildUrl() - { - $_SERVER['SERVER_NAME'] = 'www.example.com'; - $this->assertEquals('http://www.example.com/test.php?foo=bar', HttpUtil::buildUrl('/test.php?foo=bar', array('port' => 80))); - $this->assertEquals('https://www.example.com/', HttpUtil::buildUrl('/', array('scheme' => 'https'))); - $this->assertEquals('ftp://ftp.example.com/pub', HttpUtil::buildUrl('/pub', array('host' => 'ftp.example.com', 'port' => 21))); - } - - function test_negotiateLanguage() - { - $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en, de;q=0.5, it-IT; q = 0.5 '; - $this->assertEquals('de', HttpUtil::negotiateLanguage(array('de','it'), $r)); - $this->assertEquals(array('de'=>0.5,'it'=>0.45), $r); - } - - function test_negotiateCharset() - { - $_SERVER['HTTP_ACCEPT_CHARSET'] = ' iso-8859-1, Unicode ;q=0 , utf-8 '; - $this->assertEquals('iso-8859-1', HttpUtil::negotiateCharset(array('utf-8','iso-8859-1'), $r)); - $this->assertEquals(array('iso-8859-1'=>1000.0,'utf-8'=>999.0), $r); - } - - function test_negotiateContentType() - { - $_SERVER['HTTP_ACCEPT'] = ' text/xml+xhtml, text/html;q = .9, *'; - $this->assertEquals('text/xml+xhtml', HttpUtil::negotiateContentType(array('text/xml+xhtml', 'text/html'), $r)); - $this->assertEquals(array('text/xml+xhtml'=>1000.0,'text/html'=>0.9), $r); - } - - function test_matchModified() - { - $_SERVER['HTTP_IF_MODIFIED_SINCE'] = 'Fri, 02 Jan 1970 00:00:01 GMT'; - $this->assertTrue(HttpUtil::matchModified(1)); - $this->assertFalse(HttpUtil::matchModified(2*24*60*60+1)); - unset($_SERVER['HTTP_IF_MODIFIED_SINCE']); - - $_SERVER['HTTP_IF_UNMODIFIED_SINCE'] = 'Fri, 02 Jan 1970 00:00:01 GMT'; - $this->assertTrue(HttpUtil::matchModified(1, true)); - $this->assertFalse(HttpUtil::matchModified(2*24*60*60+1, true)); - unset($_SERVER['HTTP_IF_UNMODIFIED_SINCE']); - } - - function test_matchEtag() - { - $_SERVER['HTTP_IF_NONE_MATCH'] = '"abc"'; - $this->assertTrue(HttpUtil::matchEtag('abc')); - $this->assertFalse(HttpUtil::matchEtag('ABC')); - unset($_SERVER['HTTP_IF_NONE_MATCH']); - - $_SERVER['HTTP_IF_MATCH'] = '"abc"'; - $this->assertTrue(HttpUtil::matchEtag('abc', true)); - $this->assertFalse(HttpUtil::matchEtag('ABC', true)); - unset($_SERVER['HTTP_IF_MATCH']); - - $_SERVER['HTTP_IF_NONE_MATCH'] = '*'; - $this->assertTrue(HttpUtil::matchEtag('abc')); - $this->assertTrue(HttpUtil::matchEtag('ABC')); - unset($_SERVER['HTTP_IF_NONE_MATCH']); - - $_SERVER['HTTP_IF_MATCH'] = '*'; - $this->assertTrue(HttpUtil::matchEtag('abc', true)); - $this->assertTrue(HttpUtil::matchEtag('ABC', true)); - unset($_SERVER['HTTP_IF_MATCH']); - } - - function test_matchRequestHeader() - { - $_SERVER['HTTP_FOO'] = 'FoObAr'; - $this->assertTrue(HttpUtil::matchRequestHeader('foo', 'foobar', false)); - $this->assertTrue(HttpUtil::matchRequestHeader('foo', 'FoObAr', true)); - $this->assertFalse(HttpUtil::matchRequestHeader('foo', 'foobar', true)); - } - - function test_zlib() - { - if ($support = http_support(HTTP_SUPPORT_ENCODINGS)) { - $this->assertEquals(file_get_contents(__FILE__), http_inflate(http_deflate(file_get_contents(__FILE__), HTTP_DEFLATE_TYPE_GZIP))); - $this->assertEquals(file_get_contents(__FILE__), http_inflate(http_deflate(file_get_contents(__FILE__)))); - } else { - $this->assertFalse($support); - } - } -} - -$s = new PHPUnit2_Framework_TestSuite('HttpUtilTest'); -$p = new PHPUnit2_TextUI_ResultPrinter(); -$p->printResult($s->run(), 0); - -echo "Done\n"; -?> ---EXPECTF-- -%sTEST - - -Time: 0 - -OK (9 tests) -Done