</lead>
<date>2013-11-22</date>
<version>
- <release>2.0.0</release>
+ <release>2.0.1</release>
<api>2.0.0</api>
</version>
<stability>
</stability>
<license>BSD, revised</license>
<notes><![CDATA[
-Extended HTTP support. Again.
-
-Keep in mind that it's got the major version 2, because it's incompatible with pecl_http v1.
+* Fixed a bug with multiple ob_start(http\Env\Response) while replacing the body
+* Some Windows fixes
]]></notes>
<contents>
<dir name="/">
<file role="test" name="envresponse012.phpt"/>
<file role="test" name="envresponse013.phpt"/>
<file role="test" name="envresponse014.phpt"/>
+ <file role="test" name="envresponse015.phpt"/>
<file role="test" name="envresponsebody001.phpt"/>
<file role="test" name="envresponsebody002.phpt"/>
<file role="test" name="envresponsecodes.phpt"/>
#ifndef PHP_EXT_HTTP_H
#define PHP_EXT_HTTP_H
-#define PHP_PECL_HTTP_VERSION "2.0.0"
+#define PHP_PECL_HTTP_VERSION "2.0.1dev"
extern zend_module_entry http_module_entry;
#define phpext_http_ptr &http_module_entry
PHP_HTTP_ENV_RESPONSE_OBJECT_INIT(obj);
- if (obj->body || SUCCESS == php_http_new(NULL, php_http_message_body_class_entry, (php_http_new_t) php_http_message_body_object_new_ex, NULL, (void *) php_http_message_body_init(&obj->message->body, NULL TSRMLS_CC), (void *) &obj->body TSRMLS_CC)) {
- php_http_message_body_append(obj->message->body, ob_str, ob_len);
- RETURN_TRUE;
- }
- RETURN_FALSE;
+ php_http_message_object_init_body_object(obj);
+ php_http_message_body_append(obj->message->body, ob_str, ob_len);
+ RETURN_TRUE;
}
}
return SUCCESS;
}
+STATUS php_http_message_object_init_body_object(php_http_message_object_t *obj)
+{
+ TSRMLS_FETCH_FROM_CTX(obj);
+
+ php_http_message_body_addref(obj->message->body);
+ return php_http_new(NULL, php_http_message_body_class_entry, (php_http_new_t) php_http_message_body_object_new_ex, NULL, obj->message->body, (void *) &obj->body TSRMLS_CC);
+}
+
zend_object_value php_http_message_object_new(zend_class_entry *ce TSRMLS_DC)
{
return php_http_message_object_new_ex(ce, NULL, NULL TSRMLS_CC);
PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
if (!obj->body) {
- php_http_message_body_addref(obj->message->body);
- php_http_new(NULL, php_http_message_body_class_entry, (php_http_new_t) php_http_message_body_object_new_ex, NULL, obj->message->body, (void *) &obj->body TSRMLS_CC);
+ php_http_message_object_init_body_object(obj);
+
}
if (obj->body) {
RETVAL_OBJVAL(obj->body->zv, 1);
void php_http_message_object_prepend(zval *this_ptr, zval *prepend, zend_bool top /* = 1 */ TSRMLS_DC);
void php_http_message_object_reverse(zval *this_ptr, zval *return_value TSRMLS_DC);
STATUS php_http_message_object_set_body(php_http_message_object_t *obj, zval *zbody TSRMLS_DC);
+STATUS php_http_message_object_init_body_object(php_http_message_object_t *obj);
zend_object_value php_http_message_object_new(zend_class_entry *ce TSRMLS_DC);
zend_object_value php_http_message_object_new_ex(zend_class_entry *ce, php_http_message_t *msg, php_http_message_object_t **ptr TSRMLS_DC);
}
TSRMLS_SET_CTX(body->ts);
+ if (body_ptr) {
+ *body_ptr = body;
+ }
+
return body;
}
--- /dev/null
+--TEST--
+env response send replaced body using multiple ob_start
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+
+$r = new http\Env\Response;
+
+ob_start($r);
+echo "bar";
+ob_end_flush();
+
+$b = $r->getBody();
+$r->setBody(new http\Message\Body);
+
+ob_start($r);
+echo "foo: $b\n";
+ob_end_flush();
+
+$f = fopen("php://memory", "r+");
+
+$r->send($f);
+
+fseek($f, 0, SEEK_SET);
+echo stream_get_contents($f);
+
+?>
+--EXPECT--
+HTTP/1.1 200 OK
+Accept-Ranges: bytes
+ETag: "fc8305a1"
+
+foo: bar