From: Michael Wallner Date: Tue, 31 May 2005 12:29:14 +0000 (+0000) Subject: - add put methods for HttpRequest X-Git-Tag: RELEASE_0_8_0~8 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=c9dd13f9dfb719ff9831f0c2c19b812fa583aba3;p=m6w6%2Fext-http - add put methods for HttpRequest --- diff --git a/http_methods.c b/http_methods.c index 980245c..a8e0560 100644 --- a/http_methods.c +++ b/http_methods.c @@ -1726,6 +1726,29 @@ PHP_METHOD(HttpRequest, addPostFile) } /* }}} */ +/* {{{ proto bool HttpRequest::setPostFiles() + * + * Set files to post. + * Overwrites previously set post files. + * Affects only POST requests. + */ +PHP_METHOD(HttpRequest, setPostFiles) +{ + zval *files, *pFiles; + getObject(http_request_object, obj); + + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &files)) { + RETURN_FALSE; + } + + pFiles = GET_PROP(obj, postFiles); + zend_hash_clean(Z_ARRVAL_P(pFiles)); + array_copy(files, pFiles); + + RETURN_TRUE; +} +/* }}} */ + /* {{{ proto array HttpRequest::getPostFiles() * * Get all previously added POST files. @@ -1763,6 +1786,59 @@ PHP_METHOD(HttpRequest, unsetPostFiles) } /* }}} */ +/* {{{ proto bool HttpRequest::SetPutFile(string file) + * + * Set file to put. + * Affects only PUT requests. + */ +PHP_METHOD(HttpRequest, setPutFile) +{ + char *file; + int file_len; + getObject(http_request_object, obj); + + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_len)) { + RETURN_FALSE; + } + + UPD_PROP(obj, string, putFile, file); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto string HttpRequest::getPutFile() + * + * Get previously set put file. + */ +PHP_METHOD(HttpRequest, getPutFile) +{ + NO_ARGS; + + IF_RETVAL_USED { + zval *putfile; + getObject(http_request_object, obj); + + putfile = GET_PROP(obj, putFile); + RETVAL_STRINGL(Z_STRVAL_P(putfile), Z_STRLEN_P(putfile), 1); + } +} +/* }}} */ + +/* {{{ proto void HttpRequest::unsetPutFile() + * + * Unset file to put. + * Affects only PUT requests. + */ +PHP_METHOD(HttpRequest, unsetPutFile) +{ + getObject(http_request_object, obj); + + NO_ARGS; + + UPD_PROP(obj, string, putFile, ""); +} +/* }}} */ + /* {{{ proto array HttpRequest::getResponseData() * * Get all response data after the request has been sent. diff --git a/http_request_object.c b/http_request_object.c index ea7e9d3..d9dd8f2 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -77,10 +77,15 @@ zend_function_entry http_request_object_fe[] = { PHP_ME(HttpRequest, addPostFields, NULL, ZEND_ACC_PUBLIC) PHP_ME(HttpRequest, unsetPostFields, NULL, ZEND_ACC_PUBLIC) + PHP_ME(HttpRequest, setPostFiles, NULL, ZEND_ACC_PUBLIC) PHP_ME(HttpRequest, addPostFile, NULL, ZEND_ACC_PUBLIC) PHP_ME(HttpRequest, getPostFiles, NULL, ZEND_ACC_PUBLIC) PHP_ME(HttpRequest, unsetPostFiles, NULL, ZEND_ACC_PUBLIC) + PHP_ME(HttpRequest, setPutFile, NULL, ZEND_ACC_PUBLIC) + PHP_ME(HttpRequest, getPutFile, NULL, ZEND_ACC_PUBLIC) + PHP_ME(HttpRequest, unsetPutFile, NULL, ZEND_ACC_PUBLIC) + PHP_ME(HttpRequest, send, NULL, ZEND_ACC_PUBLIC) PHP_ME(HttpRequest, getResponseData, NULL, ZEND_ACC_PUBLIC) @@ -177,7 +182,7 @@ static inline void _http_request_object_declare_default_properties(TSRMLS_D) DCL_PROP(PROTECTED, string, url, ""); DCL_PROP(PROTECTED, string, contentType, ""); DCL_PROP(PROTECTED, string, queryData, ""); - DCL_PROP(PROTECTED, string, postFields, ""); + DCL_PROP(PROTECTED, string, putFile, ""); } void _http_request_object_free(zend_object *object TSRMLS_DC) diff --git a/php_http_request_object.h b/php_http_request_object.h index 6755669..57051b7 100644 --- a/php_http_request_object.h +++ b/php_http_request_object.h @@ -73,8 +73,12 @@ PHP_METHOD(HttpRequest, getPostFields); PHP_METHOD(HttpRequest, addPostFields); PHP_METHOD(HttpRequest, unsetPostFields); PHP_METHOD(HttpRequest, addPostFile); +PHP_METHOD(HttpRequest, setPostFiles); PHP_METHOD(HttpRequest, getPostFiles); PHP_METHOD(HttpRequest, unsetPostFiles); +PHP_METHOD(HttpRequest, setPutFile); +PHP_METHOD(HttpRequest, getPutFile); +PHP_METHOD(HttpRequest, unsetPutFile); PHP_METHOD(HttpRequest, send); PHP_METHOD(HttpRequest, getResponseData); PHP_METHOD(HttpRequest, getResponseHeader);