X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=http_request_object.c;h=ad6e43202b1b421c88773427ad1dd2e06d89675d;hb=5aa958980652d72433ba8e9e500b8dfd123d56a1;hp=5e233adabf44a62c6044d0af5c607b64eefd5e5a;hpb=08bec19979c75a45978c7c7a7c6d7926a9d5322e;p=m6w6%2Fext-http diff --git a/http_request_object.c b/http_request_object.c index 5e233ad..ad6e432 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -302,7 +302,7 @@ PHP_MINIT_FUNCTION(http_request_object) zend_object_value _http_request_object_new(zend_class_entry *ce TSRMLS_DC) { - return http_request_object_new_ex(ce, curl_easy_init(), NULL); + return http_request_object_new_ex(ce, NULL, NULL); } zend_object_value _http_request_object_new_ex(zend_class_entry *ce, CURL *ch, http_request_object **ptr TSRMLS_DC) @@ -338,6 +338,7 @@ zend_object_value _http_request_object_clone_obj(zval *this_ptr TSRMLS_DC) old_zo = zend_objects_get_address(this_ptr TSRMLS_CC); new_ov = http_request_object_new_ex(old_zo->ce, curl_easy_duphandle(old_obj->request->ch), &new_obj); + http_curl_init_ex(new_obj->request->ch, new_obj->request, new_obj->request->_error); zend_objects_clone_members(&new_obj->zo, new_ov, old_zo, Z_OBJ_HANDLE_P(this_ptr) TSRMLS_CC); phpstr_append(&new_obj->history, old_obj->history.data, old_obj->history.used); @@ -436,7 +437,7 @@ STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_ STATUS status = SUCCESS; http_request_reset(obj->request); - HTTP_CHECK_CURL_INIT(obj->request->ch, curl_easy_init(), return FAILURE); + HTTP_CHECK_CURL_INIT(obj->request->ch, http_curl_init(obj->request), return FAILURE); obj->request->url = http_absolute_url(Z_STRVAL_P(GET_PROP(url))); @@ -502,8 +503,10 @@ STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_ fields = (Z_TYPE_P(zfields) == IS_ARRAY) ? Z_ARRVAL_P(zfields) : NULL; files = (Z_TYPE_P(zfiles) == IS_ARRAY) ? Z_ARRVAL_P(zfiles) : NULL; - if (!(obj->request->body = http_request_body_fill(obj->request->body, fields, files))) { - status = FAILURE; + if ((fields && zend_hash_num_elements(fields)) || (files && zend_hash_num_elements(files))) { + if (!(obj->request->body = http_request_body_fill(obj->request->body, fields, files))) { + status = FAILURE; + } } } }