X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_cache_api.c;h=5eca48a6650576054b7b8a844e1da6a89b8c7bf2;hp=49843598a9425a03aed447ac7dd7cfe05915540b;hb=2e1cd7f9942bb07d7c3a2efb79090215fc1406d6;hpb=a347d63a12d0863cf848c2e4ffa891fe827e29bb diff --git a/http_cache_api.c b/http_cache_api.c index 4984359..5eca48a 100644 --- a/http_cache_api.c +++ b/http_cache_api.c @@ -33,12 +33,37 @@ #include "php_http_send_api.h" #include "php_http_date_api.h" -#ifdef HAVE_LIBMHASH +#ifdef HTTP_HAVE_MHASH # include #endif ZEND_EXTERN_MODULE_GLOBALS(http); +STATUS _http_cache_global_init(INIT_FUNC_ARGS) +{ + HTTP_LONG_CONSTANT("HTTP_ETAG_MD5", HTTP_ETAG_MD5); + HTTP_LONG_CONSTANT("HTTP_ETAG_SHA1", HTTP_ETAG_SHA1); + HTTP_LONG_CONSTANT("HTTP_ETAG_CRC32", HTTP_ETAG_CRC32); + +#ifdef HTTP_HAVE_MHASH + { + int l, i, c = mhash_count(); + + for (i = 0; i <= c; ++i) { + char const_name[256] = {0}; + const char *hash_name = mhash_get_hash_name_static(i); + + if (hash_name) { + l = snprintf(const_name, 255, "HTTP_ETAG_MHASH_%s", hash_name); + zend_register_long_constant(const_name, l + 1, i, CONST_CS|CONST_PERSISTENT, module_number TSRMLS_CC); + } + } + } +#endif + + return SUCCESS; +} + /* {{{ char *http_etag(void *, size_t, http_send_mode) */ PHP_HTTP_API char *_http_etag(const void *data_ptr, size_t data_len, http_send_mode data_mode TSRMLS_DC) { @@ -190,7 +215,7 @@ PHP_HTTP_API STATUS _http_cache_etag(const char *etag, size_t etag_len, return SUCCESS; } - if (HTTP_G(etag).started = (SUCCESS == php_start_ob_buffer_named("ob_etaghandler", HTTP_SENDBUF_SIZE, 1 TSRMLS_CC))) { + if (HTTP_G(etag).started = (SUCCESS == php_start_ob_buffer_named("ob_etaghandler", HTTP_G(send).buffer_size, 1 TSRMLS_CC))) { return SUCCESS; } else { return FAILURE; @@ -202,9 +227,6 @@ PHP_HTTP_API STATUS _http_cache_etag(const char *etag, size_t etag_len, PHP_HTTP_API void _http_ob_etaghandler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC) { - char etag[41] = { 0 }; - unsigned char digest[20]; - if (mode & PHP_OUTPUT_HANDLER_START) { if (HTTP_G(etag).started) { http_error(HE_WARNING, HTTP_E_RUNTIME, "ob_etaghandler can only be used once");