From 58086cbfebfd1725a3b77b4cb7ce2b5c9f6d9d4c Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 18 Jun 2010 21:04:26 +0200 Subject: [PATCH] src/action_graph.c: Send a "Last-Modified" header. --- src/action_graph.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/action_graph.c b/src/action_graph.c index f43f997..148921c 100644 --- a/src/action_graph.c +++ b/src/action_graph.c @@ -119,7 +119,8 @@ static int ag_info_print (rrd_info_t *info) /* {{{ */ return (0); } /* }}} int ag_info_print */ -static int output_graph (rrd_info_t *info) /* {{{ */ +static int output_graph (rrd_info_t *info, /* {{{ */ + time_t mtime) { rrd_info_t *img; @@ -132,9 +133,19 @@ static int output_graph (rrd_info_t *info) /* {{{ */ return (ENOENT); printf ("Content-Type: image/png\n" - "Content-Length: %lu\n" - "\n", + "Content-Length: %lu\n", img->value.u_blo.size); + if (mtime > 0) + { + char buffer[256]; + int status; + + status = time_to_rfc1123 (mtime, buffer, sizeof (buffer)); + if (status == 0) + printf ("Last-Modified: %s\n", buffer); + } + printf ("\n"); + fwrite (img->value.u_blo.ptr, img->value.u_blo.size, /* nmemb = */ 1, stdout); @@ -193,7 +204,7 @@ int action_graph (void) /* {{{ */ { int status; - status = output_graph (info); + status = output_graph (info, inst_get_mtime (inst)); if (status != 0) { rrd_info_t *ptr; -- 2.11.0