[xiph-commits] r3515 - liboggz/trunk/src/tools/oggz-chop

conrad at svn.annodex.net conrad at svn.annodex.net
Thu Mar 20 14:43:28 PDT 2008


Author: conrad
Date: 2008-03-20 14:43:28 -0700 (Thu, 20 Mar 2008)
New Revision: 3515

Modified:
   liboggz/trunk/src/tools/oggz-chop/cgi.c
Log:
generate Last-Modified HTTP headers in oggz-chop CGI mode


Modified: liboggz/trunk/src/tools/oggz-chop/cgi.c
===================================================================
--- liboggz/trunk/src/tools/oggz-chop/cgi.c	2008-03-20 21:42:39 UTC (rev 3514)
+++ liboggz/trunk/src/tools/oggz-chop/cgi.c	2008-03-20 21:43:28 UTC (rev 3515)
@@ -127,7 +127,8 @@
   char * path_translated;
   char * query_string;
   char * if_modified_since;
-  time_t since_time;
+  time_t since_time, last_time;
+  struct stat statbuf;
 
   httpdate_init ();
 
@@ -143,27 +144,29 @@
 
   /*photo_init (&params->in, path_translated);*/
 
+  /* Get Last-Modified time */
+  if (stat (path_translated, &statbuf) == -1) {
+    switch (errno) {
+    case ENOENT:
+      return 0;
+    default:
+      fprintf (stderr, "oggz-chop: Error checking %s: %s\n",
+               path_translated, strerror(errno));
+      return -1;
+    }
+  }
+
+  last_time = statbuf.st_mtime;
+
   if (if_modified_since != NULL) {
-    struct stat statbuf;
     int len;
 
     fprintf (stderr, "If-Modified-Since: %s\n", if_modified_since);
 
-    if (stat (path_translated, &statbuf) == -1) {
-      switch (errno) {
-      case ENOENT:
-        return 0;
-      default:
-        fprintf (stderr, "oggz-chop: Error checking %s: %s\n",
-                 path_translated, strerror(errno));
-        return -1;
-      }
-    }
-
     len = strlen (if_modified_since) + 1;
     since_time = httpdate_parse (if_modified_since, len);
 
-    if (statbuf.st_mtime <= since_time) {
+    if (last_time <= since_time) {
       header_not_modified();
       header_end();
       return 1;
@@ -172,6 +175,8 @@
 
   header_content_type_ogg ();
 
+  header_last_modified (last_time);
+
   /*config_init (params);*/
 
   parse_query (state, query_string);



More information about the commits mailing list