o = ecalloc(1, sizeof(*o));
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
- zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
object_properties_init((zend_object *) o, ce);
-#endif
+
ov.handle = zend_objects_store_put(o, NULL, php_http_client_object_free, NULL TSRMLS_CC);
ov.handlers = &php_http_client_object_handlers;
PHP_HTTP_ARG_OBJ(http\\Client, client, 0)
PHP_HTTP_END_ARGS;
-static void php_http_client_datashare_object_write_prop(zval *object, zval *member, zval *value
-#if PHP_VERSION_ID >= 50400
-, const zend_literal *literal_key
-#endif
-TSRMLS_DC);
+static void php_http_client_datashare_object_write_prop(zval *object, zval *member, zval *value PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC);
static zend_class_entry *php_http_client_datashare_class_entry;
o = ecalloc(1, sizeof(*o));
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
- zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
object_properties_init((zend_object *) o, ce);
-#endif
ov.handle = zend_objects_store_put(o, NULL, php_http_client_datashare_object_free, NULL TSRMLS_CC);
ov.handlers = &php_http_client_datashare_object_handlers;
efree(o);
}
-static void php_http_client_datashare_object_write_prop(zval *object, zval *member, zval *value
-#if PHP_VERSION_ID >= 50400
-, const zend_literal *literal_key
-#endif
-TSRMLS_DC)
+static void php_http_client_datashare_object_write_prop(zval *object, zval *member, zval *value PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC)
{
zend_property_info *pi;
}
}
- zend_get_std_object_handlers()->write_property(object, member, value
-#if PHP_VERSION_ID >= 50400
- , literal_key
-#endif
- TSRMLS_CC);
+ zend_get_std_object_handlers()->write_property(object, member, value PHP_HTTP_ZEND_LITERAL_CC TSRMLS_CC);
}
-static zval **php_http_client_datashare_object_get_prop_ptr(zval *object, zval *member
-#if PHP_VERSION_ID >= 50400
-, const zend_literal *literal_key
-#endif
-TSRMLS_DC)
+static zval **php_http_client_datashare_object_get_prop_ptr(zval *object, zval *member PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC)
{
zend_property_info *pi;
return &php_http_property_proxy_init(NULL, object, member, NULL TSRMLS_CC)->myself;
}
- return zend_get_std_object_handlers()->get_property_ptr_ptr(object, member
-#if PHP_VERSION_ID >= 50400
- , literal_key
-#endif
- TSRMLS_CC);
+ return zend_get_std_object_handlers()->get_property_ptr_ptr(object, member PHP_HTTP_ZEND_LITERAL_CC TSRMLS_CC);
}
o = ecalloc(1, sizeof(php_http_client_pool_object_t));
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
- zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
object_properties_init((zend_object *) o, ce);
-#endif
if (!(o->pool = p)) {
o->pool = php_http_client_pool_init(NULL, &php_http_client_pool_user_ops, NULL, NULL TSRMLS_CC);
o = ecalloc(sizeof(*o), 1);
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
- zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
object_properties_init((zend_object *) o, ce);
-#endif
if (list) {
o->list = list;
o = ecalloc(1, sizeof(php_http_client_object_t));
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
- zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
object_properties_init((zend_object *) o, ce);
-#endif
if (!(o->client = r)) {
o->client = php_http_client_init(NULL, &php_http_curl_client_ops, NULL, NULL TSRMLS_CC);
o = ecalloc(1, sizeof(*o));
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
- zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
object_properties_init((zend_object *) o, ce);
-#endif
if (share) {
o->share = share;
o = ecalloc(1, sizeof(php_http_client_pool_object_t));
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
- zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
object_properties_init((zend_object *) o, ce);
-#endif
if (!(o->pool = p)) {
o->pool = php_http_client_pool_init(NULL, &php_http_curl_client_pool_ops, NULL, NULL TSRMLS_CC);
o = ecalloc(1, sizeof(*o));
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
- zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
object_properties_init((zend_object *) o, ce);
-#endif
if (ptr) {
*ptr = o;
+--------------------------------------------------------------------+
| Redistribution and use in source and binary forms, with or without |
| modification, are permitted provided that the conditions mentioned |
- | in the accomp395anying LICENSE file are met. |
+ | in the accompanying LICENSE file are met. |
+--------------------------------------------------------------------+
| Copyright (c) 2004-2011, Michael Wallner <mike@php.net> |
+--------------------------------------------------------------------+
static SAPI_POST_HANDLER_FUNC(php_http_json_post_handler)
{
if (SG(request_info).raw_post_data) {
- php_json_decode_ex(arg, SG(request_info).raw_post_data, SG(request_info).raw_post_data_length, PHP_JSON_OBJECT_AS_ARRAY, PG(max_input_nesting_level) TSRMLS_CC);
+ php_json_decode(arg, SG(request_info).raw_post_data, SG(request_info).raw_post_data_length, 1, PG(max_input_nesting_level) TSRMLS_CC);
}
}
if (!(php_output_get_status(TSRMLS_C) & PHP_OUTPUT_IMPLICITFLUSH)) {
sapi_flush(TSRMLS_C);
}
+#else
+ php_end_ob_buffer(1, 1 TSRMLS_CC);
+ sapi_flush(TSRMLS_C);
#endif
php_http_sleep(r->throttle.delay);
}
}
php_http_env_get_response_headers(&message->hdrs TSRMLS_CC);
-
+#if PHP_VERSION_ID >= 50400
if (php_output_get_level(TSRMLS_C)) {
if (php_output_get_status(TSRMLS_C) & PHP_OUTPUT_SENT) {
php_http_error(HE_WARNING, PHP_HTTP_E_RUNTIME, "Could not fetch response body, output has already been sent at %s:%d", php_output_get_start_filename(TSRMLS_C), php_output_get_start_lineno(TSRMLS_C));
zval_dtor(&tval);
}
}
+#endif
break;
default:
PHP_HTTP_END_ARGS;
PHP_HTTP_EMPTY_ARGS(splitMultipartBody);
-static zval *php_http_message_object_read_prop(zval *object, zval *member, int type, const zend_literal *literal_key TSRMLS_DC);
-static void php_http_message_object_write_prop(zval *object, zval *member, zval *value, const zend_literal *literal_key TSRMLS_DC);
-static zval **php_http_message_object_get_prop_ptr(zval *object, zval *member, const zend_literal *literal_key TSRMLS_DC);
+static zval *php_http_message_object_read_prop(zval *object, zval *member, int type PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC);
+static void php_http_message_object_write_prop(zval *object, zval *member, zval *value PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC);
+static zval **php_http_message_object_get_prop_ptr(zval *object, zval *member PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC);
static HashTable *php_http_message_object_get_props(zval *object TSRMLS_DC);
static zend_class_entry *php_http_message_class_entry;
}
-static zval **php_http_message_object_get_prop_ptr(zval *object, zval *member, const zend_literal *literal_key TSRMLS_DC)
+static zval **php_http_message_object_get_prop_ptr(zval *object, zval *member PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC)
{
php_http_message_object_prophandler_t *handler;
zval *copy = php_http_ztyp(IS_STRING, member);
}
zval_ptr_dtor(©);
- return zend_get_std_object_handlers()->get_property_ptr_ptr(object, member, literal_key TSRMLS_CC);
+ return zend_get_std_object_handlers()->get_property_ptr_ptr(object, member PHP_HTTP_ZEND_LITERAL_CC TSRMLS_CC);
}
-static zval *php_http_message_object_read_prop(zval *object, zval *member, int type, const zend_literal *literal_key TSRMLS_DC)
+static zval *php_http_message_object_read_prop(zval *object, zval *member, int type PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC)
{
php_http_message_object_t *obj = zend_object_store_get_object(object TSRMLS_CC);
php_http_message_object_prophandler_t *handler;
return_value = NULL;
}
} else {
- return_value = zend_get_std_object_handlers()->read_property(object, member, type, literal_key TSRMLS_CC);
+ return_value = zend_get_std_object_handlers()->read_property(object, member, type PHP_HTTP_ZEND_LITERAL_CC TSRMLS_CC);
}
zval_ptr_dtor(©);
return return_value;
}
-static void php_http_message_object_write_prop(zval *object, zval *member, zval *value, const zend_literal *literal_key TSRMLS_DC)
+static void php_http_message_object_write_prop(zval *object, zval *member, zval *value PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC)
{
php_http_message_object_t *obj = zend_object_store_get_object(object TSRMLS_CC);
php_http_message_object_prophandler_t *handler;
if (SUCCESS == php_http_message_object_get_prophandler(Z_STRVAL_P(copy), Z_STRLEN_P(copy), &handler)) {
handler->write(obj, value TSRMLS_CC);
} else {
- zend_get_std_object_handlers()->write_property(object, member, value, literal_key TSRMLS_CC);
+ zend_get_std_object_handlers()->write_property(object, member, value PHP_HTTP_ZEND_LITERAL_CC TSRMLS_CC);
}
zval_ptr_dtor(©);
o = ecalloc(1, sizeof(php_http_message_body_object_t));
zend_object_std_init((zend_object *) o, php_http_message_body_class_entry TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
- zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
object_properties_init((zend_object *) o, ce);
-#endif
if (ptr) {
*ptr = o;
/* ZEND */
+#if PHP_VERSION_ID < 50400
+# define object_properties_init(o, ce) zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*))
+# define PHP_HTTP_ZEND_LITERAL_DC
+# define PHP_HTTP_ZEND_LITERAL_CC
+# define PHP_HTTP_ZEND_LITERAL_CCN
+# define ZVAL_COPY_VALUE(zv, arr) do { \
+ (zv)->value = (arr)->value; \
+ Z_TYPE_P(zv) = Z_TYPE_P(arr); \
+ } while (0)
+#else
+# define PHP_HTTP_ZEND_LITERAL_DC , const zend_literal *literal_key
+# define PHP_HTTP_ZEND_LITERAL_CC , (literal_key)
+# define PHP_HTTP_ZEND_LITERAL_CCN , NULL
+#endif
+
#define INIT_PZVAL_ARRAY(zv, ht) \
{ \
INIT_PZVAL((zv)); \
o = ecalloc(1, sizeof(php_http_object_t));
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
- zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
object_properties_init((zend_object *) o, ce);
-#endif
if (ptr) {
*ptr = o;
o = ecalloc(1, sizeof(*o));
zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-#if PHP_VERSION_ID < 50339
- zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
-#else
object_properties_init((zend_object *) o, ce);
-#endif
if (ptr) {
*ptr = o;
with_error_handling(EH_THROW, php_http_exception_get_class_entry()) {
if (SUCCESS == zend_parse_parameters_none()) {
with_error_handling(EH_THROW, php_http_exception_get_class_entry()) {
- zval *instance = *zend_std_get_static_property(php_http_querystring_class_entry, ZEND_STRL("instance"), 0, NULL TSRMLS_CC);
+ zval *instance = *zend_std_get_static_property(php_http_querystring_class_entry, ZEND_STRL("instance"), 0 PHP_HTTP_ZEND_LITERAL_CCN TSRMLS_CC);
if (Z_TYPE_P(instance) != IS_OBJECT) {
zval **_GET = NULL;
--- /dev/null
+<?php
+require_once "PHPUnit/Autoload.php";
+$c = new PHPUnit_TextUI_Command;
+$c->run(array_merge($argv, array(__DIR__."/phpunit/")));
function testSuppress() {
http\Object::setDefaultErrorHandling(http\Object::EH_SUPPRESS);
- (new eh)->triggerError(E_USER_WARNING, http\Exception::E_UNKNOWN, "suppress");
+ $o = new eh;
+ $o->triggerError(E_USER_WARNING, http\Exception::E_UNKNOWN, "suppress");
}
function testException() {
http\Object::setDefaultErrorHandling(http\Object::EH_THROW);
$this->setExpectedException("http\\Exception");
- (new eh)->triggerError(E_USER_WARNING, http\Exception::E_UNKNOWN, "exception");
+ $o = new eh;
+ $o->triggerError(E_USER_WARNING, http\Exception::E_UNKNOWN, "exception");
}
function testNormalError() {
http\Object::setDefaultErrorHandling(http\Object::EH_NORMAL);
$this->setExpectedException("PHPUnit_Framework_Error_Warning");
- (new eh)->triggerError(E_USER_WARNING, http\Exception::E_UNKNOWN, "warning");
+ $o = new eh;
+ $o->triggerError(E_USER_WARNING, http\Exception::E_UNKNOWN, "warning");
}
function testSuppress2() {
protected $r;
function setUp() {
- $this->r = (new http\Client\Factory)->createClient();
+ $f = new http\Client\Factory;
+ $this->r = $f->createClient();
$this->r->setOptions(
array(
"connecttimeout" => 30,
}
function testObserver() {
+ $test = $this;
$this->r->attach($o1 = new ProgressObserver1);
$this->r->attach($o2 = new ProgressObserver2);
$this->r->attach(
$o3 = new CallbackObserver(
- function ($r) {
+ function ($r) use ($test) {
$p = (array) $r->getProgress();
- $this->assertArrayHasKey("started", $p);
- $this->assertArrayHasKey("finished", $p);
- $this->assertArrayHasKey("dlnow", $p);
- $this->assertArrayHasKey("ulnow", $p);
- $this->assertArrayHasKey("dltotal", $p);
- $this->assertArrayHasKey("ultotal", $p);
- $this->assertArrayHasKey("info", $p);
+ $test->assertArrayHasKey("started", $p);
+ $test->assertArrayHasKey("finished", $p);
+ $test->assertArrayHasKey("dlnow", $p);
+ $test->assertArrayHasKey("ulnow", $p);
+ $test->assertArrayHasKey("dltotal", $p);
+ $test->assertArrayHasKey("ultotal", $p);
+ $test->assertArrayHasKey("info", $p);
}
)
);
function testArrays() {
$url = new http\Url($this->url);
- $this->assertEquals($url->toArray(), (new http\Url($url->toArray()))->toArray());
+ $url2 = new http\Url($url->toArray());
+ $this->assertEquals($url->toArray(), $url2->toArray());
}
}
if (!strlen($ext = $argv[1]))
die(sprintf("Usage: %s <ext>\n", $argv[0]));
+printf("<?php\n\n");
+
$ext = new ReflectionExtension($ext);
foreach ($ext->getConstants() as $constant => $value) {
printf("const %s = %s;\n", $constant, $value);
}
$ps[] = $p1;
}
- printf("%s) {\n\t\t}\n", implode(", ", $ps));
+ printf("%s)", implode(", ", $ps));
+ if ($m->isAbstract()) {
+ printf(";\n\n");
+ } else {
+ printf(" {\n\t\t}\n\n");
+ }
}
}
--TEST--
etags with hash
--SKIPIF--
-<?php include "skipif.inc"; _ext("hash"); ?>
+<?php
+include "skipif.inc";
+_ext("hash");
+version_compare(PHP_VERSION, "5.4.0", ">=") or die("skip PHP>=5.4 required");
+?>
--FILE--
<?php
$body = new http\Message\Body;
foreach (array("Client", "Pool", "DataShare") as $type) {
try {
- var_dump((new http\Client\Factory(array("driver" => "nonexistant")))->{"create$type"}());
+ $f = new http\Client\Factory(array("driver" => "nonexistant"));
+ var_dump($f->{"create$type"}());
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
use http\Message as HttpMessage;
+function newHttpMessage($s) {
+ return new http\Message($s);
+}
+
$s = "GET /first HTTP/1.1\nHTTP/1.1 200 Ok-first\nGET /second HTTP/1.1\nHTTP/1.1 200 Ok-second\nGET /third HTTP/1.1\nHTTP/1.1 200 Ok-third\n";
-echo (new HttpMessage($s))->toString(true);
+echo newHttpMessage($s)->toString(true);
echo "===\n";
-echo (new HttpMessage($s))->reverse()->toString(true);
+echo newHttpMessage($s)->reverse()->toString(true);
-$m = new HttpMessage($s);
+$m = newHttpMessage($s);
$r = $m->reverse();
unset($m);
var_dump($r->count());
<?php include "skipif.inc"; ?>
--FILE--
<?php
-(new http\Client\Factory(array("persistentHandleId" => "foo")))
- ->createClient()->setRequest(new http\Client\Request("GET", "http://dev.iworks.at"))
+$f = new http\Client\Factory(array("persistentHandleId" => "foo"));
+$r = $f->createClient()->setRequest(new http\Client\Request("GET", "http://dev.iworks.at"))
->setOptions(array("connecttimeout"=> 90, "timeout" =>300))
- ->send(null);
-$r = (new http\Client\Factory(array("persistentHandleId" => "bar")))
- ->createClient()->setRequest(new http\Client\Request("GET", "http://dev.iworks.at"))
+ ->send(null);
+$f = new http\Client\Factory(array("persistentHandleId" => "bar"));
+$r = $f->createClient()->setRequest(new http\Client\Request("GET", "http://dev.iworks.at"))
->setOptions(array("connecttimeout"=> 90, "timeout" =>300));
var_dump(http\Env::statPersistentHandles());
unit tests
--SKIPIF--
<?php
-@include_once "PHPUnit/Autoload.php" or die("skip need PHPUnit in include_path");
+if (!@include_once "PHPUnit/Autoload.php") die("skip need PHPUnit in include_path");
?>
--FILE--
<?php
require_once "PHPUnit/Autoload.php";
-(new PHPUnit_TextUI_Command)->run([null, __DIR__."/../phpunit"]);
+$c = new PHPUnit_TextUI_Command;
+$c->run(array("--process-isolation", __DIR__."/../phpunit/"));
?>
--EXPECTF--
PHPUnit %s by Sebastian Bergmann.
$r = new http\Env\Response;
$r->setContentType("text/plain");
$r->setContentDisposition(
- ["attachment" => ["filename" => basename(__FILE__)]]
+ array("attachment" => array("filename" => basename(__FILE__)))
);
$r->setBody(new http\Message\Body(fopen(__FILE__, "rb")));
$r->send();
$serialized = serialize($instance);
$unserialized = unserialize($serialized);
- foreach (["toString", "toArray"] as $m) {
+ foreach (array("toString", "toArray") as $m) {
if ($class->hasMethod($m)) {
#printf("%s#%s\n", $class->getName(), $m);
$unserialized->$m();
}
if ($class->hasMethod("attach") && !$class->implementsInterface("\\SplSubject")) {
#printf("%s#%s\n", $class->getName(), "attach");
- $unserialized->attach((new http\Curl\Client)->setRequest(new http\Client\Request("GET", "http://localhost")));
+ $c = new http\Curl\Client;
+ $c->setRequest(new http\Client\Request("GET", "http://localhost"));
+ $unserialized->attach($c);
}
}
}