- add put methods for HttpRequest
authorMichael Wallner <mike@php.net>
Tue, 31 May 2005 12:29:14 +0000 (12:29 +0000)
committerMichael Wallner <mike@php.net>
Tue, 31 May 2005 12:29:14 +0000 (12:29 +0000)
http_methods.c
http_request_object.c
php_http_request_object.h

index 980245c6f3bca12fa4d0659d25368a16fe1ebf73..a8e0560f285d19a62edb337e5cc47096171d0d6f 100644 (file)
@@ -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.
index ea7e9d39c9e67df637e6f08e0186da8411df9c88..d9dd8f259a858ac588df50f43520035b2a26b6b9 100644 (file)
@@ -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)
index 6755669af7afb5dfe7df3f69d278ae8f19def162..57051b710f79e1bdd0c6e1dac74ff341b1eca553 100644 (file)
@@ -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);