- add HttpRequest::getRawResponseMessage() and ::getRawRequestMessage() (Ilia)
authorMichael Wallner <mike@php.net>
Tue, 20 Dec 2005 18:55:43 +0000 (18:55 +0000)
committerMichael Wallner <mike@php.net>
Tue, 20 Dec 2005 18:55:43 +0000 (18:55 +0000)
- add 'resetcookies' request option (Ilia)
- fix wrong return by ref arg info

http_request_api.c
http_request_object.c
php_http_request_object.h
phpstr/phpstr.h

index fd1a176f9f7805488a694d271f2f466956ef6394..c12edb285535aeb880313913be4daf30fb339cc5 100644 (file)
@@ -523,6 +523,11 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti
                }
        }
 
+       /* reset cookies */
+       if ((zoption = http_request_option(request, options, "resetcookies", IS_BOOL)) && Z_LVAL_P(zoption)) {
+               HTTP_CURL_OPT(COOKIELIST, "ALL");
+       }
+
        /* session cookies */
        if ((zoption = http_request_option(request, options, "cookiesession", IS_BOOL))) {
                if (Z_LVAL_P(zoption)) {
index facd8e974e5fbd27f02efac7f9559adc38fb02f6..e189c214ed1379aa7d97bcc4223ad33ec4e15251 100644 (file)
@@ -147,11 +147,13 @@ HTTP_BEGIN_ARGS(getResponseInfo, 0, 0)
        HTTP_ARG_VAL(name, 0)
 HTTP_END_ARGS;
 
-HTTP_EMPTY_ARGS(getResponseMessage, 1);
-HTTP_EMPTY_ARGS(getRequestMessage, 1);
-HTTP_EMPTY_ARGS(getHistory, 1);
+HTTP_EMPTY_ARGS(getResponseMessage, 0);
+HTTP_EMPTY_ARGS(getRawResponseMessage, 0);
+HTTP_EMPTY_ARGS(getRequestMessage, 0);
+HTTP_EMPTY_ARGS(getRawRequestMessage, 0);
+HTTP_EMPTY_ARGS(getHistory, 0);
 HTTP_EMPTY_ARGS(clearHistory, 0);
-HTTP_EMPTY_ARGS(send, 1);
+HTTP_EMPTY_ARGS(send, 0);
 
 HTTP_BEGIN_ARGS(get, 0, 1)
        HTTP_ARG_VAL(url, 0)
@@ -267,7 +269,9 @@ zend_function_entry http_request_object_fe[] = {
        HTTP_REQUEST_ME(getResponseBody, ZEND_ACC_PUBLIC)
        HTTP_REQUEST_ME(getResponseInfo, ZEND_ACC_PUBLIC)
        HTTP_REQUEST_ME(getResponseMessage, ZEND_ACC_PUBLIC)
+       HTTP_REQUEST_ME(getRawResponseMessage, ZEND_ACC_PUBLIC)
        HTTP_REQUEST_ME(getRequestMessage, ZEND_ACC_PUBLIC)
+       HTTP_REQUEST_ME(getRawRequestMessage, ZEND_ACC_PUBLIC)
        HTTP_REQUEST_ME(getHistory, ZEND_ACC_PUBLIC)
        HTTP_REQUEST_ME(clearHistory, ZEND_ACC_PUBLIC)
 
@@ -1875,6 +1879,44 @@ PHP_METHOD(HttpRequest, getRequestMessage)
 }
 /* }}} */
 
+/* {{{ proto string HttpRequest::getRawRequestMessage()
+ *
+ * Get sent HTTP message.
+ * 
+ * Returns an HttpMessage in a form of a string 
+ * 
+ */
+PHP_METHOD(HttpRequest, getRawRequestMessage)
+{
+       NO_ARGS;
+
+       IF_RETVAL_USED {
+               getObject(http_request_object, obj);
+
+               RETURN_PHPSTR_DUP(&obj->request->conv.request);
+       }
+}
+/* }}} */
+
+/* {{{ proto string HttpRequest::getRawResponseMessage()
+ *
+ * Get the entire HTTP response.
+ * 
+ * Returns the complete web server response, including the headers in a form of a string.
+ * 
+ */
+PHP_METHOD(HttpRequest, getRawResponseMessage)
+{
+       NO_ARGS;
+
+       IF_RETVAL_USED {
+               getObject(http_request_object, obj);
+
+               RETURN_PHPSTR_DUP(&obj->request->conv.response);
+       }
+}
+/* }}} */
+
 /* {{{ proto HttpMessage HttpRequest::getHistory()
  *
  * Get all sent requests and received responses as an HttpMessage object.
index ca092ee3b2f2cb610a90b56bc3cea990a03b8b4f..35d7a379baf7d1f50b5cc45ae02419dd73ea9222 100644 (file)
@@ -85,7 +85,9 @@ PHP_METHOD(HttpRequest, getResponseCode);
 PHP_METHOD(HttpRequest, getResponseBody);
 PHP_METHOD(HttpRequest, getResponseInfo);
 PHP_METHOD(HttpRequest, getResponseMessage);
+PHP_METHOD(HttpRequest, getRawResponseMessage);
 PHP_METHOD(HttpRequest, getRequestMessage);
+PHP_METHOD(HttpRequest, getRawRequestMessage);
 PHP_METHOD(HttpRequest, getHistory);
 PHP_METHOD(HttpRequest, clearHistory);
 
index 9e18e5464df99d55ede2ecc471a7d359c5b0ef0c..03d024ef1e1f43977b80c6fdb18ee9726e76badd 100644 (file)
 
 #define RETURN_PHPSTR_PTR(STR) RETURN_PHPSTR((STR), PHPSTR_FREE_PTR, 0)
 #define RETURN_PHPSTR_VAL(STR) RETURN_PHPSTR((STR), PHPSTR_FREE_NOT, 0)
+#define RETURN_PHPSTR_DUP(STR) RETURN_PHPSTR((STR), PHPSTR_FREE_NOT, 1)
 #define RETVAL_PHPSTR_PTR(STR) RETVAL_PHPSTR((STR), PHPSTR_FREE_PTR, 0)
 #define RETVAL_PHPSTR_VAL(STR) RETVAL_PHPSTR((STR), PHPSTR_FREE_NOT, 0)
+#define RETVAL_PHPSTR_DUP(STR) RETVAƖ_PHPSTR((STR), PHPSTR_FREE_NOT, 1)
 /* RETURN_PHPSTR(buf, PHPSTR_FREE_PTR, 0) */
 #define RETURN_PHPSTR(STR, free, dup) \
        RETVAL_PHPSTR((STR), (free), (dup)); \