X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=http_request_object.c;h=ead0870361dd25e9e278f7a0d658548a3d13c5c7;hb=c5eec6611ed1dd1e9e984deb007bc11c92784451;hp=74dbe4f18d8a5be8a6e2951894d1ac1a6f71081f;hpb=5977bd2facb8a842b3ca3ee677b8014407e75941;p=m6w6%2Fext-http diff --git a/http_request_object.c b/http_request_object.c index 74dbe4f..ead0870 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -339,7 +339,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, NULL, &new_obj); if (old_obj->request->ch) { - new_obj->request->ch = http_curl_init_ex(curl_easy_duphandle(old_obj->request->ch), new_obj->request, new_obj->request->_error); + http_curl_init_ex(curl_easy_duphandle(old_obj->request->ch), new_obj->request); } zend_objects_clone_members(&new_obj->zo, new_ov, old_zo, Z_OBJ_HANDLE_P(this_ptr) TSRMLS_CC); @@ -630,7 +630,6 @@ STATUS _http_request_object_responsehandler(http_request_object *obj, zval *this static inline void _http_request_object_set_options_subr(INTERNAL_FUNCTION_PARAMETERS, char *key, size_t len, int overwrite) { zval *old_opts, *new_opts, *opts = NULL, **entry; - getObject(http_request_object, obj); if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a/!", &opts)) { RETURN_FALSE; @@ -672,10 +671,8 @@ static inline void _http_request_get_options_subr(INTERNAL_FUNCTION_PARAMETERS, IF_RETVAL_USED { zval *opts, **options; - getObject(http_request_object, obj); opts = GET_PROP(options); - array_init(return_value); if ( (Z_TYPE_P(opts) == IS_ARRAY) && @@ -706,7 +703,6 @@ PHP_METHOD(HttpRequest, __construct) int URL_len; long meth = -1; zval *options = NULL; - getObject(http_request_object, obj); SET_EH_THROW_HTTP(); if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sla", &URL, &URL_len, &meth, &options)) { @@ -740,7 +736,6 @@ PHP_METHOD(HttpRequest, setOptions) ulong idx = 0; HashPosition pos; zval *opts = NULL, *old_opts, *new_opts, *add_opts, **opt; - getObject(http_request_object, obj); if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!/", &opts)) { RETURN_FALSE; @@ -944,7 +939,6 @@ PHP_METHOD(HttpRequest, setUrl) { char *URL = NULL; int URL_len; - getObject(http_request_object, obj); if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &URL, &URL_len)) { RETURN_FALSE; @@ -983,12 +977,16 @@ PHP_METHOD(HttpRequest, getUrl) PHP_METHOD(HttpRequest, setMethod) { long meth; - getObject(http_request_object, obj); if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &meth)) { RETURN_FALSE; } + if (meth >= HTTP_GET && meth <= HTTP_PUT) { + getObject(http_request_object, obj); + curl_easy_setopt(obj->request->ch, CURLOPT_CUSTOMREQUEST, NULL); + } + UPD_PROP(long, method, meth); RETURN_TRUE; } @@ -1126,7 +1124,6 @@ PHP_METHOD(HttpRequest, addQueryData) zval *qdata, *old_qdata; char *query_data = NULL; size_t query_data_len = 0; - getObject(http_request_object, obj); if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &qdata)) { RETURN_FALSE; @@ -1158,7 +1155,6 @@ PHP_METHOD(HttpRequest, addQueryData) PHP_METHOD(HttpRequest, addPostFields) { zval *post_data, *old_post, *new_post; - getObject(http_request_object, obj); if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &post_data)) { RETURN_FALSE; @@ -1193,7 +1189,6 @@ PHP_METHOD(HttpRequest, addPostFields) PHP_METHOD(HttpRequest, setPostFields) { zval *post, *post_data = NULL; - getObject(http_request_object, obj); if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/!", &post_data)) { RETURN_FALSE; @@ -1243,7 +1238,6 @@ PHP_METHOD(HttpRequest, setRawPostData) { char *raw_data = NULL; int data_len = 0; - getObject(http_request_object, obj); if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &raw_data, &data_len)) { RETURN_FALSE; @@ -1271,7 +1265,6 @@ PHP_METHOD(HttpRequest, addRawPostData) { char *raw_data; int data_len; - getObject(http_request_object, obj); if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &raw_data, &data_len)) { RETURN_FALSE; @@ -1325,7 +1318,6 @@ PHP_METHOD(HttpRequest, addPostFile) zval *entry, *old_post, *new_post; char *name, *file, *type = NULL; int name_len, file_len, type_len = 0; - getObject(http_request_object, obj); if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|s", &name, &name_len, &file, &file_len, &type, &type_len)) { RETURN_FALSE; @@ -1373,7 +1365,6 @@ PHP_METHOD(HttpRequest, addPostFile) PHP_METHOD(HttpRequest, setPostFiles) { zval *files = NULL, *post; - getObject(http_request_object, obj); if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a!/", &files)) { RETURN_FALSE; @@ -1420,7 +1411,6 @@ PHP_METHOD(HttpRequest, setPutFile) { char *file = ""; int file_len = 0; - getObject(http_request_object, obj); if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &file, &file_len)) { RETURN_FALSE; @@ -1487,7 +1477,6 @@ PHP_METHOD(HttpRequest, getResponseHeader) zval *data, **headers, **header; char *header_name = NULL; int header_len = 0; - getObject(http_request_object, obj); if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &header_name, &header_len)) { RETURN_FALSE; @@ -1532,7 +1521,6 @@ PHP_METHOD(HttpRequest, getResponseCookie) zval *data, **headers; char *cookie_name = NULL; int cookie_len = 0; - getObject(http_request_object, obj); if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &cookie_name, &cookie_len)) { RETURN_FALSE; @@ -1633,7 +1621,6 @@ PHP_METHOD(HttpRequest, getResponseBody) IF_RETVAL_USED { zval **body; - getObject(http_request_object, obj); zval *data = GET_PROP(responseData); if ( (Z_TYPE_P(data) == IS_ARRAY) && @@ -1687,7 +1674,6 @@ PHP_METHOD(HttpRequest, getResponseInfo) zval *info, **infop; char *info_name = NULL; int info_len = 0; - getObject(http_request_object, obj); if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &info_name, &info_len)) { RETURN_FALSE; @@ -1732,7 +1718,6 @@ PHP_METHOD(HttpRequest, getResponseMessage) IF_RETVAL_USED { zval *message; - getObject(http_request_object, obj); SET_EH_THROW_HTTP(); message = GET_PROP(responseMessage);