X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http.c;h=452ec8f86a98fed4ea6e2e4e17c2a43fd6f69372;hp=535a5aebe9a0dada0bdea5882a1819a8e68c4ae5;hb=0f9c41f499873dbd4ab88469d838922554a49a99;hpb=0d215d4f181f34af40fad377570919dc978ff563 diff --git a/http.c b/http.c index 535a5ae..452ec8f 100644 --- a/http.c +++ b/http.c @@ -457,7 +457,7 @@ PHP_FUNCTION(http_cache_etag) /* if no etag is given and we didn't already start ob_etaghandler -- start it */ if (!HTTP_G(etag_started)) { - RETURN_BOOL(HTTP_G(etag_started) = (SUCCESS == http_start_ob_handler(_http_ob_etaghandler, "ob_etaghandler", 0, 1))); + RETURN_BOOL(HTTP_G(etag_started) = (SUCCESS == http_start_ob_handler(_http_ob_etaghandler, "ob_etaghandler", 4096, 1))); } RETURN_TRUE; } @@ -465,31 +465,34 @@ PHP_FUNCTION(http_cache_etag) /* {{{ proto string ob_httpetaghandler(string data, int mode) * - * For use with ob_start(). Note that this has to be started as first output buffer. + * For use with ob_start(). + * Note that this has to be started as first output buffer. + * WARNING: Don't use with http_send_*(). */ PHP_FUNCTION(ob_httpetaghandler) { char *data; int data_len; long mode; - + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &data, &data_len, &mode)) { RETURN_FALSE; } - + if (mode & PHP_OUTPUT_HANDLER_START) { if (HTTP_G(etag_started)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "ob_etaghandler can only be used once"); - RETURN_FALSE; - } - if (OG(ob_nesting_level)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "must be started prior to other output buffers"); - RETURN_FALSE; + php_error_docref(NULL TSRMLS_CC, E_WARNING, "ob_httpetaghandler can only be used once"); + RETURN_STRINGL(data, data_len, 1); } http_send_header("Cache-Control: private, must-revalidate, max-age=0"); HTTP_G(etag_started) = 1; } - + + if (OG(ob_nesting_level) > 1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "ob_httpetaghandler must be started prior to other output buffers"); + RETURN_STRINGL(data, data_len, 1); + } + Z_TYPE_P(return_value) = IS_STRING; http_ob_etaghandler(data, data_len, &Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value), mode); }