fi
])
+dnl ----
+dnl JSON
+dnl ----
+ HTTP_HAVE_PHP_EXT([json])
+
+
dnl ----
dnl ICONV
dnl ----
dnl shared extension deps
HTTP_SHARED_DEP([hash])
HTTP_SHARED_DEP([iconv])
+ HTTP_SHARED_DEP([json])
PHP_SUBST([HTTP_SHARED_LIBADD])
#ifdef PHP_HTTP_HAVE_ICONV
ZEND_MOD_REQUIRED("iconv")
#endif
+#ifdef PHP_HTTP_HAVE_JSON
+ ZEND_MOD_REQUIRED("json")
+#endif
#ifdef PHP_HTTP_HAVE_EVENT
ZEND_MOD_CONFLICTS("event")
#endif
# define PHP_HTTP_HAVE_HASH
#endif
+#if (defined(HAVE_JSON) || defined(PHP_HTTP_HAVE_EXT_JSON)) && (PHP_HTTP_SHARED_DEPS || !defined(COMPILE_DL_JSON))
+# define PHP_HTTP_HAVE_JSON
+#endif
+
#ifdef PHP_WIN32
# define CURL_STATICLIB
# define PHP_HTTP_HAVE_NETDB
PHP_METHOD(HttpClientFactory, createPool)
{
int argc = 0;
- zval ***argv;
+ zval ***argv = NULL;
with_error_handling(EH_THROW, php_http_exception_get_class_entry()) {
- if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|*", &argv, &argc)) {
+ if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "*", &argv, &argc)) {
with_error_handling(EH_THROW, php_http_exception_get_class_entry()) {
int i;
zval *zdriver;
zval ***argv;
with_error_handling(EH_THROW, php_http_exception_get_class_entry()) {
- if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|*", &argv, &argc)) {
+ if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "*", &argv, &argc)) {
with_error_handling(EH_THROW, php_http_exception_get_class_entry()) {
int i;
zval *zdriver;
}
}
+#ifdef PHP_HTTP_HAVE_JSON
+#include "ext/json/php_json.h"
+
+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);
+ }
+}
+
+#endif
+
PHP_MINIT_FUNCTION(http_env)
{
+#ifdef PHP_HTTP_HAVE_JSON
+ sapi_post_entry entry = {NULL, 0, NULL, NULL};
+
+ entry.post_reader = sapi_read_standard_form_data;
+ entry.post_handler = php_http_json_post_handler;
+
+ entry.content_type = "text/json";
+ entry.content_type_len = lenof("text/json");
+ sapi_register_post_entry(&entry TSRMLS_CC);
+
+ entry.content_type = "application/json";
+ entry.content_type_len = lenof("application/json");
+ sapi_register_post_entry(&entry TSRMLS_CC);
+#endif
+
PHP_HTTP_REGISTER_CLASS(http, Env, http_env, NULL, 0);
return SUCCESS;
$p = $f->createPool();
$s = $f->createDataShare();
+$r->setRequest(new http\Client\Request("GET", "http://localhost/"));
+$x = $f->createPool($r);
+$y = $f->createDatashare($r);
+
var_dump(
- array_map("get_class", array($f,$r,$p,$s)),
+ array_map("get_class", array($f,$r,$p,$s,$x,$y)),
$f->getDriver()
);
?>
--EXPECTF--
Test
-array(4) {
+array(6) {
[0]=>
string(9) "MyFactory"
[1]=>
string(6) "MyPool"
[3]=>
string(7) "MyShare"
+ [4]=>
+ string(6) "MyPool"
+ [5]=>
+ string(7) "MyShare"
}
string(4) "curl"
clients are not supported by this driver