#ifdef ZEND_ENGINE_2
+#include "missing.h"
+
ZEND_EXTERN_MODULE_GLOBALS(http)
/* {{{ HttpResponse */
}
/* }}} */
-/* {{{ proto bool HttpResponse::send()
+/* {{{ proto bool HttpResponse::send([bool clean_ob = true])
*
* Finally send the entity.
*
*/
PHP_METHOD(HttpResponse, send)
{
+ zend_bool clean_ob = 1;
zval *do_cache, *do_gzip;
getObject(http_response_object, obj);
- NO_ARGS;
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &clean_ob)) {
+ RETURN_FALSE;
+ }
do_cache = GET_PROP(obj, cache);
do_gzip = GET_PROP(obj, gzip);
+ if (clean_ob) {
+ /* interrupt on-the-fly etag generation */
+ HTTP_G(etag).started = 0;
+ /* discard previous output buffers */
+ php_end_ob_buffers(0 TSRMLS_CC);
+ }
+
/* gzip */
if (Z_LVAL_P(do_gzip)) {
php_start_ob_buffer_named("ob_gzhandler", 0, 1 TSRMLS_CC);
/* {{{ HttpMessage */
-/* {{{ proto static HttpMessage HttpMessage::fromString(string raw_message)
- *
- * Create an HttpMessage object from a string.
- */
-PHP_METHOD(HttpMessage, fromString)
-{
- char *string = NULL;
- int length = 0;
- http_message *msg = NULL;
- http_message_object obj;
-
- if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &length)) {
- RETURN_NULL();
- }
-
- if (!(msg = http_message_parse(string, length))) {
- RETURN_NULL();
- }
-
- Z_TYPE_P(return_value) = IS_OBJECT;
- return_value->value.obj = http_message_object_from_msg(msg);
-}
-/* }}} */
-
/* {{{ proto void HttpMessage::__construct([string message])
*
* Instantiate a new HttpMessage object.
}
/* }}} */
+/* {{{ proto static HttpMessage HttpMessage::fromString(string raw_message)
+ *
+ * Create an HttpMessage object from a string.
+ */
+PHP_METHOD(HttpMessage, fromString)
+{
+ char *string = NULL;
+ int length = 0;
+ http_message *msg = NULL;
+
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &length)) {
+ RETURN_NULL();
+ }
+
+ if (!(msg = http_message_parse(string, length))) {
+ RETURN_NULL();
+ }
+
+ Z_TYPE_P(return_value) = IS_OBJECT;
+ return_value->value.obj = http_message_object_from_msg(msg);
+}
+/* }}} */
+
/* {{{ proto string HttpMessage::getBody()
*
* Get the body of the parsed Message.
NO_ARGS;
IF_RETVAL_USED {
- zval *uri;
getObject(http_message_object, obj);
if (!HTTP_MSG_TYPE(REQUEST, obj->message)) {
PHP_METHOD(HttpMessage, setHttpVersion)
{
char v[4];
- zval *zv, *version;
+ zval *zv;
getObject(http_message_object, obj);
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/", &zv)) {
}
/* }}} */
+/* {{{ 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.
}
/* }}} */
+/* {{{ 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.