}
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;
+ }
}
/* }}} */
/* {{{ 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;
}
#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);
}
}
HTTP_DEFLATE_TYPE_GZIP : HTTP_DEFLATE_TYPE_ZLIB);
#endif
}
+ /* flush headers */
+ sapi_flush(TSRMLS_C);
}
/* }}} */
#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;
}
}
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();
}
}
{
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);
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);
}
<email>mike@php.net</email>
<active>yes</active>
</lead>
- <date>2006-11-05</date>
+ <date>2006-11-22</date>
<version>
<release>1.4.0dev</release>
<api>1.4.0</api>
</stability>
<license>BSD, revised</license>
<notes><![CDATA[
+* Improved response performance
+ Added "ipresolve" request option
+ Added HTTP_IPRESOLVE_{ANY|V4|V6}, HttpRequest::IPRESOLVE_{ANY|V4|V6} constants
+ Added missing HTTP_SSL_VERSION_{ANY|TLSv1|SSLv2|SSLv3}, HttpRequest::SSL_VERSION_{ANY|TLSv1|SSLv2|SSLv3} constants
<file role="test" name="stream_filters_001.phpt"/>
<file role="test" name="stream_filters_002.phpt"/>
<file role="test" name="stream_filters_003.phpt"/>
- <file role="test" name="ut_HttpMessage.phpt"/>
- <file role="test" name="ut_HttpUtil.phpt"/>
</dir>
</dir>
</contents>
zend_bool force_exit;
zend_bool read_post_data;
+ zval *server_var;
ZEND_END_MODULE_GLOBALS(http)
#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
checkmin(5.1);
skipif(!http_support(HTTP_SUPPORT_ENCODINGS), "need zlib support");
?>
+--ENV--
+HTTP_IF_NONE_MATCH="900150983cd24fb0d6963f7d28e17f72"
+HTTP_ACCEPT_ENCODING=gzip
--FILE--
<?php
-$_SERVER["HTTP_IF_NONE_MATCH"] = '"900150983cd24fb0d6963f7d28e17f72"';
-$_SERVER["HTTP_ACCEPT_ENCODING"] = "gzip";
HttpResponse::setGzip(true);
HttpResponse::setCache(true);
HttpResponse::setCacheControl('public', 3600);
<?php
include 'skip.inc';
?>
+--ENV--
+HTTP_HOST=www.example.com
--FILE--
<?php
-$_SERVER['HTTP_HOST'] = 'www.example.com';
$url = '/path/?query#anchor';
echo "-TEST\n";
printf("-%s-\n", http_build_url($url));
<?php
include 'skip.inc';
?>
+--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--
<?php
echo "-TEST\n";
-$_SERVER['HTTP_ACCEPT'] = 'application/xml, application/xhtml+xml, text/html ; q = .8';
-$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'de-AT,de-DE;q=0.8,en-GB;q=0.3,en-US;q=0.2';
-$_SERVER['HTTP_ACCEPT_CHARSET'] = 'ISO-8859-1,utf-8;q=0.7,*;q=0.7';
$langs = array(
array('de', 'en', 'es'),
);
include 'skip.inc';
checkcgi();
?>
+--ENV--
+HTTP_RANGE=bytes=-5
--FILE--
<?php
-$_SERVER['HTTP_RANGE'] = 'bytes=-5';
http_send_content_type('text/plain');
http_send_data(str_repeat('123abc', 1000));
?>
Content-Range: bytes 5995-5999/6000
Content-Length: 5
-23abc
\ No newline at end of file
+23abc
include 'skip.inc';
checkcgi();
?>
+--ENV--
+HTTP_RANGE=bytes=5-6
--FILE--
<?php
-$_SERVER['HTTP_RANGE'] = 'bytes=5-6';
http_send_content_type('text/plain');
http_send_data(str_repeat('123abc', 1000));
?>
Content-Range: bytes 5-6/6000
Content-Length: 2
-c1
\ No newline at end of file
+c1
include 'skip.inc';
checkcgi();
?>
+--ENV--
+HTTP_RANGE=bytes=5981-
--FILE--
<?php
-$_SERVER['HTTP_RANGE'] = 'bytes=5981-';
http_send_content_type('text/plain');
http_send_data(str_repeat('123abc', 1000));
?>
Content-Range: bytes 5981-5999/6000
Content-Length: 19
-c123abc123abc123abc
\ No newline at end of file
+c123abc123abc123abc
include 'skip.inc';
checkcgi();
?>
+--ENV--
+HTTP_RANGE=bytes=5990-6000
--FILE--
<?php
-$_SERVER['HTTP_RANGE'] = 'bytes=5990-6000';
http_send_content_type('text/plain');
http_send_data(str_repeat('123abc', 1000));
?>
--EXPECTF--
Status: 416
-%s
\ No newline at end of file
+%s
checkcgi();
checkver(5.1);
?>
+--ENV--
+HTTP_RANGE=bytes=0-1
+HTTP_IF_UNMODIFIED_SINCE=Thu, 01 Jan 1970 00:16:40 GMT
--FILE--
<?php
-$_SERVER['HTTP_RANGE'] = 'bytes=0-1';
-$_SERVER['HTTP_IF_UNMODIFIED_SINCE'] = http_date(10000);
http_cache_last_modified();
http_send_file(__FILE__);
?>
include 'skip.inc';
checkcgi();
?>
+--ENV--
+HTTP_RANGE=bytes=0-3, 4-5,9-11
--FILE--
<?php
-$_SERVER['HTTP_RANGE'] = 'bytes=0-3, 4-5,9-11';
http_send_content_type('text/plain');
http_send_file('data.txt');
?>
checkcgi();
checkmin(5.1);
?>
+--ENV--
+HTTP_RANGE=bytes=5-9
--FILE--
<?php
-$_SERVER['HTTP_RANGE'] = 'bytes=5-9';
http_send_file('data.txt');
?>
--EXPECTF--
checkcgi();
checkmin(5.1);
?>
+--ENV--
+HTTP_RANGE=bytes=-9
--FILE--
<?php
-$_SERVER['HTTP_RANGE'] = 'bytes=-9';
http_send_file('data.txt');
?>
--EXPECTF--
checkcgi();
checkmin(5.1);
?>
+--ENV--
+HTTP_RANGE=bytes=1000-
--FILE--
<?php
-$_SERVER['HTTP_RANGE'] = 'bytes=1000- ';
http_send_file('data.txt');
?>
--EXPECTF--
checkcgi();
checkmin(5.1);
?>
+--ENV--
+HTTP_RANGE=bytes=-1111
--FILE--
<?php
-$_SERVER['HTTP_RANGE'] = 'bytes=-1111';
http_send_file('data.txt');
?>
--EXPECTF--
include 'skip.inc';
checkcgi();
?>
+--ENV--
+HTTP_RANGE=bytes=0-1
+HTTP_IF_RANGE="abc"
--FILE--
<?php
-$_SERVER['HTTP_RANGE'] = 'bytes=0-1';
-$_SERVER['HTTP_IF_RANGE'] = '"abc"';
http_cache_etag('abc');
http_send_file(__FILE__);
?>
include 'skip.inc';
checkcgi();
?>
+--ENV--
+HTTP_RANGE=bytes=0-1
+HTTP_IF_RANGE="abcd"
--FILE--
<?php
-$_SERVER['HTTP_RANGE'] = 'bytes=0-1';
-$_SERVER['HTTP_IF_RANGE'] = '"abcd"';
http_cache_etag('abc');
http_send_file(__FILE__);
?>
+++ /dev/null
---TEST--
-PHPUnit HttpMessage
---SKIPIF--
-<?php
-include 'skip.inc';
-checkcls('HttpMessage');
-skipif(!@include 'PHPUnit2/Framework/TestCase.php', 'need PHPUnit2');
-?>
---FILE--
-<?php
-echo "-TEST\n";
-
-error_reporting(E_ALL);
-ini_set('html_errors', 0);
-
-require_once 'PHPUnit2/Framework/TestSuite.php';
-require_once 'PHPUnit2/Framework/TestCase.php';
-require_once 'PHPUnit2/TextUI/ResultPrinter.php';
-
-class HttpMessageTest extends PHPUnit2_Framework_TestCase
-{
- function setUp()
- {
- $this->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
+++ /dev/null
---TEST--
-PHPUnit HttpRequest
---SKIPIF--
-<?php
-include 'skip.inc';
-checkcls('HttpRequest');
-skipif(!@include 'PHPUnit2/Framework/TestCase.php', 'need PHPUnit2');
-?>
---FILE--
-<?php
-echo "-TEST\n";
-
-error_reporting(E_ALL);
-ini_set('html_errors', 0);
-
-require_once 'PHPUnit2/Framework/TestSuite.php';
-require_once 'PHPUnit2/Framework/TestCase.php';
-require_once 'PHPUnit2/TextUI/ResultPrinter.php';
-
-class HttpRequestTest extends PHPUnit2_Framework_TestCase
-{
- function test___construct()
- {
- }
-
- function test___destruct()
- {
- }
-
- function test_setOptions()
- {
- }
-
- function test_getOptions()
- {
- }
-
- function test_setSslOptions()
- {
- }
-
- function test_getSslOptions()
- {
- }
-
- function test_addHeaders()
- {
- }
-
- function test_getHeaders()
- {
- }
-
- function test_setHeaders()
- {
- }
-
- function test_addCookies()
- {
- }
-
- function test_getCookies()
- {
- }
-
- function test_setCookies()
- {
- }
-
- function test_setMethod()
- {
- }
-
- function test_getMethod()
- {
- }
-
- function test_setUrl()
- {
- }
-
- function test_getUrl()
- {
- }
-
- function test_setContentType()
- {
- }
-
- function test_getContentType()
- {
- }
-
- function test_setQueryData()
- {
- }
-
- function test_getQueryData()
- {
- }
-
- function test_addQueryData()
- {
- }
-
- function test_setPostFields()
- {
- }
-
- function test_getPostFields()
- {
- }
-
- function test_addPostFields()
- {
- }
-
- function test_setRawPostData()
- {
- }
-
- function test_getRawPostData()
- {
- }
-
- function test_addRawPostData()
- {
- }
-
- function test_setPostFiles()
- {
- }
-
- function test_addPostFile()
- {
- }
-
- function test_getPostFiles()
- {
- }
-
- function test_setPutFile()
- {
- }
-
- function test_getPutFile()
- {
- }
-
- function test_send()
- {
- }
-
- function test_getResponseData()
- {
- }
-
- function test_getResponseHeader()
- {
- }
-
- function test_getResponseCookie()
- {
- }
-
- function test_getResponseCode()
- {
- }
-
- function test_getResponseBody()
- {
- }
-
- function test_getResponseInfo()
- {
- }
-
- function test_getResponseMessage()
- {
- }
-
- function test_getRequestMessage()
- {
- }
-
- function test_getHistory()
- {
- }
-
- function test_clearHistory()
- {
- }
-
- function test_get()
- {
- }
-
- function test_head()
- {
- }
-
- function test_postData()
- {
- }
-
- function test_postFields()
- {
- }
-
- function test_putFile()
- {
- }
-
- function test_putStream()
- {
- }
-
- function test_methodRegister()
- {
- }
-
- function test_methodUnregister()
- {
- }
-
- function test_methodName()
- {
- }
-
- function test_methodExists()
- {
- }
-
-
-}
-
-$s = new PHPUnit2_Framework_TestSuite('HttpRequestTest');
-$p = new PHPUnit2_TextUI_ResultPrinter();
-$p->printResult($s->run(), 0);
-
-echo "Done\n";
-?>
---EXPECTF--
-%sTEST
-
-
-Time: 0
-
-OK (53 tests)
-Done
+++ /dev/null
---TEST--
-PHPUnit HttpRequestPool
---SKIPIF--
-<?php
-include 'skip.inc';
-checkcls('HttpRequestPool');
-skipif(!@include 'PHPUnit2/Framework/TestCase.php', 'need PHPUnit2');
-?>
---FILE--
-<?php
-echo "-TEST\n";
-
-error_reporting(E_ALL);
-ini_set('html_errors', 0);
-
-require_once 'PHPUnit2/Framework/TestSuite.php';
-require_once 'PHPUnit2/Framework/TestCase.php';
-require_once 'PHPUnit2/TextUI/ResultPrinter.php';
-
-class HttpRequestPoolTest extends PHPUnit2_Framework_TestCase
-{
- function test___construct()
- {
- }
-
- function test___destruct()
- {
- }
-
- function test_attach()
- {
- }
-
- function test_detach()
- {
- }
-
- function test_send()
- {
- }
-
- function test_reset()
- {
- }
-
- function test_socketPerform()
- {
- }
-
- function test_socketSelect()
- {
- }
-
- function test_valid()
- {
- }
-
- function test_current()
- {
- }
-
- function test_key()
- {
- }
-
- function test_next()
- {
- }
-
- function test_rewind()
- {
- }
-
- function test_count()
- {
- }
-
- function test_getAttachedRequests()
- {
- }
-
- function test_getFinishedRequests()
- {
- }
-
-
-}
-
-$s = new PHPUnit2_Framework_TestSuite('HttpRequestPoolTest');
-$p = new PHPUnit2_TextUI_ResultPrinter();
-$p->printResult($s->run(), 0);
-
-echo "Done\n";
-?>
---EXPECTF--
-%sTEST
-
-
-Time: 0
-
-OK (16 tests)
-Done
+++ /dev/null
---TEST--
-PHPUnit HttpUtil
---SKIPIF--
-<?php
-include 'skip.inc';
-checkcls('HttpUtil');
-skipif(!@include 'PHPUnit2/Framework/TestCase.php', 'need PHPUnit2');
-?>
---FILE--
-<?php
-echo "-TEST\n";
-
-error_reporting(E_ALL);
-ini_set('html_errors', 0);
-
-require_once 'PHPUnit2/Framework/TestSuite.php';
-require_once 'PHPUnit2/Framework/TestCase.php';
-require_once 'PHPUnit2/TextUI/ResultPrinter.php';
-
-class HttpUtilTest extends PHPUnit2_Framework_TestCase
-{
- function test_date()
- {
- $this->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