- if ((zdriver = zend_read_property(php_http_request_factory_class_entry, getThis(), ZEND_STRL("driver"), 0 TSRMLS_CC))
- && (IS_STRING == Z_TYPE_P(zdriver))
- && (SUCCESS == php_http_request_factory_get_driver(Z_STRVAL_P(zdriver), Z_STRLEN_P(zdriver), &driver))
- && (driver.request_ops)
- && (req = php_http_request_init(NULL, driver.request_ops, NULL TSRMLS_CC))
- && (SUCCESS == php_http_new(&ov, class_entry, (php_http_new_t) php_http_request_object_new_ex, php_http_request_class_entry, req, NULL TSRMLS_CC))
- ) {
- ZVAL_OBJVAL(return_value, ov, 0);
-
- MAKE_STD_ZVAL(os);
- object_init_ex(os, spl_ce_SplObjectStorage);
- zend_update_property(php_http_request_class_entry, return_value, ZEND_STRL("observers"), os TSRMLS_CC);
- zval_ptr_dtor(&os);
-
- if (url_str) {
- zend_update_property_stringl(php_http_request_class_entry, return_value, ZEND_STRL("url"), url_str, url_len TSRMLS_CC);
- }
- if (meth > 0) {
- zend_update_property_long(php_http_request_class_entry, return_value, ZEND_STRL("method"), meth TSRMLS_CC);
- }
- if (options) {
- zend_call_method_with_1_params(&return_value, Z_OBJCE_P(return_value), NULL, "setoptions", NULL, options);
+ zdriver = zend_read_property(php_http_request_factory_class_entry, getThis(), ZEND_STRL("driver"), 0 TSRMLS_CC);
+
+ if ((IS_STRING == Z_TYPE_P(zdriver)) && (SUCCESS == php_http_request_factory_get_driver(Z_STRVAL_P(zdriver), Z_STRLEN_P(zdriver), &driver)) && driver.request_ops) {
+ zval *phi = php_http_zsep(1, IS_STRING, zend_read_property(php_http_request_factory_class_entry, getThis(), ZEND_STRL("persistentHandleId"), 0 TSRMLS_CC));
+ php_http_resource_factory_t *rf = NULL;
+
+ if (Z_STRLEN_P(phi)) {
+ char *name_str;
+ size_t name_len;
+ php_http_persistent_handle_factory_t *pf;
+
+ name_len = spprintf(&name_str, 0, "http_request.%s", Z_STRVAL_P(zdriver));
+
+ if ((pf = php_http_persistent_handle_concede(NULL , name_str, name_len, Z_STRVAL_P(phi), Z_STRLEN_P(phi) TSRMLS_CC))) {
+ rf = php_http_resource_factory_init(NULL, php_http_persistent_handle_resource_factory_ops(), pf, (void (*)(void *)) php_http_persistent_handle_abandon);
+ }
+
+ efree(name_str);