diff mbox series

[2/2] Generate ETag similar to Nginx and BusyBox HTTPD

Message ID 20210112222057.26876-3-stokito@gmail.com
State New
Headers show
Series uhttpd: Generate ETag similar to Nginx and BusyBox HTTPD | expand

Commit Message

Sergey Ponomarev Jan. 12, 2021, 10:20 p.m. UTC
Thus user run Luci on them and all cached files will work as previous because ETag is the same.
---
 file.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/file.c b/file.c
index 759ffd6..e0a4fb3 100644
--- a/file.c
+++ b/file.c
@@ -300,8 +300,9 @@  static const char * uh_file_mime_lookup(const char *path)
 
 static const char * uh_file_mktag(struct stat *s, char *buf, int len)
 {
+	/* ETag is "hex(last_mod)-hex(file_size)" e.g. "5e132e20-417" */
 	snprintf(buf, len, "\"%" PRIx64 "-%" PRIx64 "\"",
-		s->st_size, (uint64_t)s->st_mtime);
+		(uint64_t)s->st_mtime, s->st_size);
 
 	return buf;
 }