From: Michael Wallner Date: Tue, 20 Dec 2005 18:55:43 +0000 (+0000) Subject: - add HttpRequest::getRawResponseMessage() and ::getRawRequestMessage() (Ilia) X-Git-Tag: RELEASE_0_21_0~56 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=40e535bf0ccece715c2ccc640148fab5ebd9a053;p=m6w6%2Fext-http - add HttpRequest::getRawResponseMessage() and ::getRawRequestMessage() (Ilia) - add 'resetcookies' request option (Ilia) - fix wrong return by ref arg info --- diff --git a/http_request_api.c b/http_request_api.c index fd1a176..c12edb2 100644 --- a/http_request_api.c +++ b/http_request_api.c @@ -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)) { diff --git a/http_request_object.c b/http_request_object.c index facd8e9..e189c21 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -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. diff --git a/php_http_request_object.h b/php_http_request_object.h index ca092ee..35d7a37 100644 --- a/php_http_request_object.h +++ b/php_http_request_object.h @@ -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); diff --git a/phpstr/phpstr.h b/phpstr/phpstr.h index 9e18e54..03d024e 100644 --- a/phpstr/phpstr.h +++ b/phpstr/phpstr.h @@ -54,8 +54,10 @@ #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)); \