X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=http_response_object.c;h=5bdbf14fc2c22509be1da373c374cfe0dda012aa;hb=9a35b7682fede86cb0167d21a67fea38a6e85181;hp=f7cb216c5ba4bbf0f52a31544f7080caff8cc813;hpb=19cad54672b6babfac2b7c9c64c415c9a24b888a;p=m6w6%2Fext-http diff --git a/http_response_object.c b/http_response_object.c index f7cb216..5bdbf14 100644 --- a/http_response_object.c +++ b/http_response_object.c @@ -25,6 +25,7 @@ #include "SAPI.h" #include "php_ini.h" +#include "ext/standard/head.h" #include "php_http.h" #include "php_http_api.h" @@ -47,6 +48,7 @@ ZEND_EXTERN_MODULE_GLOBALS(http); #define HTTP_BEGIN_ARGS(method, req_args) HTTP_BEGIN_ARGS_EX(HttpResponse, method, 0, req_args) #define HTTP_EMPTY_ARGS(method, ret_ref) HTTP_EMPTY_ARGS_EX(HttpResponse, method, ret_ref) #define HTTP_RESPONSE_ME(method, visibility) PHP_ME(HttpResponse, method, HTTP_ARGS(HttpResponse, method), visibility|ZEND_ACC_STATIC) +#define HTTP_RESPONSE_ALIAS(method, func) HTTP_STATIC_ME_ALIAS(method, func, HTTP_ARGS(HttpResponse, method)) HTTP_EMPTY_ARGS(getETag, 0); HTTP_BEGIN_ARGS(setETag, 1) @@ -111,6 +113,26 @@ HTTP_END_ARGS; HTTP_EMPTY_ARGS(capture, 0); +HTTP_BEGIN_ARGS(redirect, 0) + HTTP_ARG_VAL(url, 0) + HTTP_ARG_VAL(params, 0) + HTTP_ARG_VAL(session, 0) + HTTP_ARG_VAL(permanent, 0) +HTTP_END_ARGS; + +HTTP_BEGIN_ARGS(sendStatus, 1) + HTTP_ARG_VAL(status, 0) +HTTP_END_ARGS; + +HTTP_BEGIN_ARGS(sendHeader, 1) + HTTP_ARG_VAL(header, 0) + HTTP_ARG_VAL(replace, 0) + HTTP_ARG_VAL(status, 0) +HTTP_END_ARGS; + +HTTP_EMPTY_ARGS(getRequestHeaders, 0); +HTTP_EMPTY_ARGS(getRequestBody, 0); + #define http_response_object_declare_default_properties() _http_response_object_declare_default_properties(TSRMLS_C) static inline void _http_response_object_declare_default_properties(TSRMLS_D); @@ -153,6 +175,14 @@ zend_function_entry http_response_object_fe[] = { HTTP_RESPONSE_ME(send, ZEND_ACC_PUBLIC) HTTP_RESPONSE_ME(capture, ZEND_ACC_PUBLIC) + HTTP_RESPONSE_ALIAS(redirect, http_redirect) + + HTTP_RESPONSE_ALIAS(sendStatus, http_send_status) + HTTP_RESPONSE_ALIAS(sendHeader, header) + + HTTP_RESPONSE_ALIAS(getRequestHeaders, http_get_request_headers) + HTTP_RESPONSE_ALIAS(getRequestBody, http_get_request_body) + {NULL, NULL, NULL} }; @@ -181,8 +211,6 @@ static inline void _http_response_object_declare_default_properties(TSRMLS_D) DCL_STATIC_PROP_N(PROTECTED, contentDisposition); DCL_STATIC_PROP(PROTECTED, long, bufferSize, HTTP_SENDBUF_SIZE); DCL_STATIC_PROP(PROTECTED, double, throttleDelay, 0.0); - - DCL_STATIC_PROP(PUBLIC, string, dummy, "EMPTY"); } /* ### USERLAND ### */ @@ -273,7 +301,7 @@ PHP_METHOD(HttpResponse, setCacheControl) } if (strcmp(ccontrol, "public") && strcmp(ccontrol, "private") && strcmp(ccontrol, "no-cache")) { - http_error_ex(E_WARNING, HTTP_E_PARAM, "Cache-Control '%s' doesn't match public, private or no-cache", ccontrol); + http_error_ex(HE_WARNING, HTTP_E_INVALID_PARAM, "Cache-Control '%s' doesn't match public, private or no-cache", ccontrol); RETURN_FALSE; } else { USE_STATIC_PROP(); @@ -313,7 +341,7 @@ PHP_METHOD(HttpResponse, setContentType) } if (!strchr(ctype, '/')) { - http_error_ex(E_WARNING, HTTP_E_PARAM, "Content type '%s' doesn't seem to contain a primary and a secondary part", ctype); + http_error_ex(HE_WARNING, HTTP_E_INVALID_PARAM, "Content type '%s' doesn't seem to contain a primary and a secondary part", ctype); RETURN_FALSE; } @@ -608,13 +636,13 @@ PHP_METHOD(HttpResponse, send) RETURN_FALSE; } if (SG(headers_sent)) { - http_error(E_WARNING, HTTP_E_HEADER, "Cannot send HttpResponse, headers have already been sent"); + http_error(HE_WARNING, HTTP_E_RESPONSE, "Cannot send HttpResponse, headers have already been sent"); RETURN_FALSE; } sent = GET_STATIC_PROP(sent); if (Z_LVAL_P(sent)) { - http_error(E_WARNING, HTTP_E_UNKOWN, "Cannot send HttpResponse, response has already been sent"); + http_error(HE_WARNING, HTTP_E_RESPONSE, "Cannot send HttpResponse, response has already been sent"); RETURN_FALSE; } else { Z_LVAL_P(sent) = 1;