aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_cache.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2003-11-04 22:12:39 +0000
committerIgor Sysoev <igor@sysoev.ru>2003-11-04 22:12:39 +0000
commit9cc1acef18220cfc3b66d0a761f1f7c39e0b5c29 (patch)
tree8c40a56b42bd6d0071bdd3f683cf1b520fd502a8 /src/http/ngx_http_cache.c
parentf60b1a5cd9f6e509caf4513f1b28ae33cb3dae4e (diff)
downloadnginx-9cc1acef18220cfc3b66d0a761f1f7c39e0b5c29.tar.gz
nginx-9cc1acef18220cfc3b66d0a761f1f7c39e0b5c29.zip
nginx-0.0.1-2003-11-05-01:12:39 import
Diffstat (limited to 'src/http/ngx_http_cache.c')
-rw-r--r--src/http/ngx_http_cache.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/http/ngx_http_cache.c b/src/http/ngx_http_cache.c
index 4e7cf0ef8..ffe7ad5aa 100644
--- a/src/http/ngx_http_cache.c
+++ b/src/http/ngx_http_cache.c
@@ -8,12 +8,12 @@
int ngx_http_cache_get_file(ngx_http_request_t *r, ngx_http_cache_ctx_t *ctx)
{
- ssize_t n;
- MD5_CTX md5;
- ngx_err_t err;
- ngx_http_cache_file_t *h;
+ ssize_t n;
+ MD5_CTX md5;
+ ngx_err_t err;
+ ngx_http_cache_header_t *h;
- ctx->header_size = sizeof(ngx_http_cache_file_t) + ctx->key.len + 1;
+ ctx->header_size = sizeof(ngx_http_cache_header_t) + ctx->key.len + 1;
ctx->file.name.len = ctx->path->name.len + 1 + ctx->path->len + 32;
if (!(ctx->file.name.data = ngx_palloc(r->pool, ctx->file.name.len + 1))) {
@@ -24,8 +24,15 @@ int ngx_http_cache_get_file(ngx_http_request_t *r, ngx_http_cache_ctx_t *ctx)
MD5Init(&md5);
MD5Update(&md5, (u_char *) ctx->key.data, ctx->key.len);
+ MD5Final(ctx->md5, &md5);
+
+ ngx_print_md5(
+ ctx->file.name.data + ctx->path->name.len + 1 + ctx->path->len,
+ ctx->md5);
+#if 0
MD5End(&md5,
ctx->file.name.data + ctx->path->name.len + 1 + ctx->path->len);
+#endif
ngx_log_debug(r->connection->log, "URL: %s, md5: %s" _ ctx->key.data _
ctx->file.name.data + ctx->path->name.len + 1 + ctx->path->len);
@@ -64,8 +71,11 @@ ngx_log_debug(r->connection->log, "FILE: %s" _ ctx->file.name.data);
return NGX_ERROR;
}
- h = (ngx_http_cache_file_t *) ctx->buf->pos;
- ctx->header = h->header;
+ h = (ngx_http_cache_header_t *) ctx->buf->pos;
+ ctx->expires = h->expires;
+ ctx->last_modified= h->last_modified;
+ ctx->date = h->date;
+ ctx->length = h->length;
if (h->key_len != ctx->key.len
|| ngx_strncmp(h->key, ctx->key.data, h->key_len) != 0)
@@ -79,7 +89,7 @@ ngx_log_debug(r->connection->log, "FILE: %s" _ ctx->file.name.data);
ctx->buf->last += n;
- if (ctx->header.expires < ngx_time()) {
+ if (ctx->expires < ngx_time()) {
return NGX_HTTP_CACHE_STALE;
}