Changeset 140

Show
Ignore:
Timestamp:
02/15/06 21:12:41 (3 years ago)
Author:
conrad
Message:

add a Last-Modified header to all CGI requests

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • fastphoto/trunk/src/cgi.c

    r139 r140  
    123123cgi_send (fastphoto_t * params) 
    124124{ 
     125  header_last_modified (params->in.mtime); 
     126 
    125127  if (params->unmodified) { 
    126128    cgi_send_photo (&params->in); 
  • fastphoto/trunk/src/header.c

    r134 r140  
    44#include <stdlib.h> 
    55#include <string.h> 
     6#include <time.h> 
    67 
    78#define CONTENT_TYPE_JPEG "Content-Type: image/jpeg\n" 
     9 
     10static char * wdays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; 
     11static char * months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", 
     12                          "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; 
     13 
     14static int 
     15http_date_snprint (char * buf, int n, time_t mtime) 
     16{ 
     17  struct tm * g; 
     18 
     19  g = gmtime (&mtime); 
     20 
     21  return snprintf (buf, n, "%s, %02d %s %4d %2d:%02d:%02d GMT", 
     22                   wdays[g->tm_wday], g->tm_mday, months[g->tm_mon], 
     23                   g->tm_year + 1900, g->tm_hour, g->tm_min, g->tm_sec); 
     24} 
     25 
     26int 
     27header_last_modified (time_t mtime) 
     28{ 
     29  char buf[30]; 
     30 
     31  http_date_snprint (buf, 30, mtime); 
     32  return printf ("Last-Modified: %s\n", buf); 
     33} 
    834 
    935int 
  • fastphoto/trunk/src/header.h

    r131 r140  
    44int header_content_type_jpeg (void); 
    55int header_content_length (int len); 
     6int header_last_modified (time_t mtime); 
    67int header_end (void); 
    78