zval **single_header;
switch (Z_TYPE_PP(header)) {
+ case IS_BOOL:
+ phpstr_appendf(&str, "%s: %s" HTTP_CRLF, key.str, Z_BVAL_PP(header)?"true":"false");
+ break;
+
+ case IS_LONG:
+ phpstr_appendf(&str, "%s: %ld" HTTP_CRLF, key.str, Z_LVAL_PP(header));
+ break;
+
+ case IS_DOUBLE:
+ phpstr_appendf(&str, "%s: %f" HTTP_CRLF, key.str, Z_DVAL_PP(header));
+ break;
+
case IS_STRING:
phpstr_appendf(&str, "%s: %s" HTTP_CRLF, key.str, Z_STRVAL_PP(header));
break;
case IS_ARRAY:
FOREACH_VAL(pos2, *header, single_header) {
- phpstr_appendf(&str, "%s: %s" HTTP_CRLF, key.str, Z_STRVAL_PP(single_header));
+ switch (Z_TYPE_PP(single_header)) {
+ case IS_BOOL:
+ phpstr_appendf(&str, "%s: %s" HTTP_CRLF, key.str, Z_BVAL_PP(single_header)?"true":"false");
+ break;
+
+ case IS_LONG:
+ phpstr_appendf(&str, "%s: %ld" HTTP_CRLF, key.str, Z_LVAL_PP(single_header));
+ break;
+
+ case IS_DOUBLE:
+ phpstr_appendf(&str, "%s: %f" HTTP_CRLF, key.str, Z_DVAL_PP(single_header));
+ break;
+
+ case IS_STRING:
+ phpstr_appendf(&str, "%s: %s" HTTP_CRLF, key.str, Z_STRVAL_PP(single_header));
+ break;
+ }
}
break;
}
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &body, &len)) {
phpstr_dtor(PHPSTR(obj->message));
- phpstr_from_string_ex(PHPSTR(obj->message), body, len);
+ phpstr_from_string_ex(PHPSTR(obj->message), body, len);
+ phpstr_fix(PHPSTR(obj->message));
}
}
/* }}} */
zval_copy_ctor(&body);
sapi_module.treat_data(PARSE_STRING, Z_STRVAL(body), &post TSRMLS_CC);
zend_call_method_with_1_params(&return_value, http_request_object_ce, NULL, "setpostfields", NULL, &post);
+ zval_dtor(&post);
}
}
#else
--- /dev/null
+--TEST--
+HttpMessage::toMessageTypeObject()
+--SKIPIF--
+<?php
+include 'skip.inc';
+checkver(5);
+checkcls('HttpRequest');
+?>
+--FILE--
+<?php
+echo "-TEST\n";
+
+$b = HttpRequest::encodeBody(array("a"=>"b",1=>2),null);
+
+$m = new HttpMessage;
+$m->setType(HttpMessage::TYPE_REQUEST);
+$m->setRequestMethod('POST');
+$m->setRequestUrl("http://www.example.com");
+$m->setHttpVersion('1.1');
+$m->addHeaders(
+ array(
+ "Content-Type" => "application/x-www-form-urlencoded",
+ "Host" => "www.example.com",
+ "Content-Length"=> strlen($b),
+ )
+);
+$m->setBody($b);
+$r = $m->toMessageTypeObject();
+echo $m,"\n";
+echo "Done\n";
+?>
+--EXPECTF--
+%aTEST
+POST http://www.example.com HTTP/1.1
+Content-Type: application/x-www-form-urlencoded
+Host: www.example.com
+Content-Length: 7
+
+a=b&1=2
+
+Done