if (php_http_message_body_size(&msg->body)) {
cb(cb_arg, ZEND_STRL(PHP_HTTP_CRLF));
php_http_message_body_to_callback(&msg->body, cb, cb_arg, 0, 0);
- cb(cb_arg, ZEND_STRL(PHP_HTTP_CRLF));
}
}
if (php_http_message_body_size(&msg->body)) {
php_http_buffer_appends(&str, PHP_HTTP_CRLF);
php_http_message_body_to_callback(&msg->body, (php_http_pass_callback_t) php_http_buffer_append, &str, 0, 0);
- php_http_buffer_appends(&str, PHP_HTTP_CRLF);
}
data = php_http_buffer_data(&str, string, length);
do {
php_http_message_to_string(message, &buf, &len);
+ php_http_buffer_prepends(&str, PHP_HTTP_CRLF);
php_http_buffer_prepend(&str, buf, len);
efree(buf);
} while ((message = message->parent));
PHP_HTTP_END_ARGS;
PHP_HTTP_BEGIN_ARGS(addPart, 1)
- PHP_HTTP_ARG_OBJ("http\\Message", "message", 0)
+ PHP_HTTP_ARG_OBJ(http\\Message, "message", 0)
PHP_HTTP_END_ARGS;
PHP_HTTP_EMPTY_ARGS(etag);
PHP_METHOD(HttpMessageBody, addPart)
{
- php_http_message_object_t *mobj;
+ zval *zobj;
- if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &mobj, php_http_message_class_entry)) {
+ if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &zobj, php_http_message_class_entry)) {
php_http_message_body_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+ php_http_message_object_t *mobj = zend_object_store_get_object(zobj TSRMLS_CC);
php_http_message_body_add_part(obj->body, mobj->message);
RETURN_TRUE;
);
}
+ function testAddPart() {
+ $this->temp->addPart(new http\Message("This: is a header\n\nand this is the data\n"));
+ $this->assertStringMatchesFormat(
+ "--%x.%x\r\n".
+ "This: is a header\r\n".
+ "Content-Length: 21\r\n".
+ "\r\n".
+ "and this is the data\n\r\n".
+ "--%x.%x--\r\n".
+ "",
+ str_replace("\r", "", $this->temp)
+ );
+ }
+
function testEtag() {
$s = stat(__FILE__);
$this->assertEquals(
Content-Length: 14
Hello, World!
-
string(3) "1.1"
bool(true)
int(200)
$m = new HttpEnvRequest();
var_dump($m);
-echo $m;
+echo $m,"\n";
var_dump((string)$m->getBody());
}
POST / HTTP/1.1%a
X-Test: test%a
+Content-Length: 3%a
+Content-Type: test/something%a
Cookie: foo=bar%a
%a
-b=c%a
+b=c
string(3) "b=c"
Done
}
}
-
===
===
Content-Disposition: form-data; name="LICENSE"; filename="LICENSE"
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
===
DONE