X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_cache_api.c;h=56ca0f61a3f045587d6e455347fa2570e435a6ca;hp=a70feb0775145664c05aafb3ddf6b6a4119b84bf;hb=3e696a1c24d6ffc382567876eafa2a5bd9b8afa7;hpb=781c90c0447166dd52ef881ae15751fa466c32fb diff --git a/http_cache_api.c b/http_cache_api.c index a70feb0..56ca0f6 100644 --- a/http_cache_api.c +++ b/http_cache_api.c @@ -18,14 +18,13 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif - #include "php.h" + +#include "SAPI.h" #include "php_streams.h" #include "php_output.h" #include "ext/standard/md5.h" -#include "SAPI.h" - #include "php_http.h" #include "php_http_std_defs.h" #include "php_http_api.h" @@ -62,6 +61,7 @@ STATUS _http_cache_exit_ex(char *cache_token, zend_bool etag, zend_bool free_tok /* {{{ 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) { + php_stream_statbuf ssb; char ssb_buf[128] = {0}; unsigned char digest[16]; PHP_MD5_CTX ctx; @@ -77,19 +77,26 @@ PHP_HTTP_API char *_http_etag(const void *data_ptr, size_t data_len, http_send_m case SEND_RSRC: { - php_stream_statbuf ssb; + if (php_stream_stat((php_stream *) data_ptr, &ssb)) { + efree(new_etag); + return NULL; + } - if (php_stream_stat((php_stream *) data_ptr, &ssb)) { - return NULL; - } snprintf(ssb_buf, 127, "%ld=%ld=%ld", ssb.sb.st_mtime, ssb.sb.st_ino, ssb.sb.st_size); PHP_MD5Update(&ctx, ssb_buf, strlen(ssb_buf)); } break; default: - efree(new_etag); - return NULL; + { + if (php_stream_stat_path(Z_STRVAL_P((zval *) data_ptr), &ssb)) { + efree(new_etag); + return NULL; + } + + snprintf(ssb_buf, 127, "%ld=%ld=%ld", ssb.sb.st_mtime, ssb.sb.st_ino, ssb.sb.st_size); + PHP_MD5Update(&ctx, ssb_buf, strlen(ssb_buf)); + } break; }