~ubuntu-branches/ubuntu/hardy/lighttpd/hardy

« back to all changes in this revision

Viewing changes to src/http-header-glue.c

  • Committer: Bazaar Package Importer
  • Author(s): Jeremie Corbier
  • Date: 2006-09-22 19:16:08 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060922191608-i9jngvf1wtf3j5rd
Tags: 1.4.12~20060907-1ubuntu1
Merge from debian unstable:
-> Keep the additional dependency on libterm-readline-perl-perl.

Show diffs side-by-side

added added

removed removed

Lines of Context:
262
262
                                                return HANDLER_FINISHED;
263
263
                                        } else {
264
264
                                                char buf[sizeof("Sat, 23 Jul 2005 21:20:01 GMT")];
265
 
 
266
 
                                                /* convert to timestamp */
267
 
                                                if (used_len < sizeof(buf)) {
268
 
                                                        time_t t_header, t_file;
269
 
                                                        struct tm tm;
270
 
                                                        
271
 
                                                        strncpy(buf, con->request.http_if_modified_since, used_len);
272
 
                                                        buf[used_len] = '\0';
273
 
                                                        
274
 
                                                        strptime(buf, "%a, %d %b %Y %H:%M:%S GMT", &tm);
275
 
                                                        t_header = mktime(&tm);
276
 
                                                        
277
 
                                                        strptime(mtime->ptr, "%a, %d %b %Y %H:%M:%S GMT", &tm);
278
 
                                                        t_file = mktime(&tm);
279
 
 
280
 
                                                        if (t_file > t_header) {
281
 
                                                                con->http_status = 304;
282
 
                                                                return HANDLER_FINISHED;
283
 
                                                        }
284
 
                                                } else {
 
265
                                                time_t t_header, t_file;
 
266
                                                struct tm tm;
 
267
 
 
268
                                                /* check if we can safely copy the string */
 
269
                                                if (used_len >= sizeof(buf)) {
285
270
                                                        log_error_write(srv, __FILE__, __LINE__, "ssdd", 
286
271
                                                                        "DEBUG: Last-Modified check failed as the received timestamp was too long:", 
287
272
                                                                        con->request.http_if_modified_since, used_len, sizeof(buf) - 1);
289
274
                                                        con->http_status = 412;
290
275
                                                        return HANDLER_FINISHED;
291
276
                                                }
 
277
 
 
278
                                                        
 
279
                                                strncpy(buf, con->request.http_if_modified_since, used_len);
 
280
                                                buf[used_len] = '\0';
 
281
                                                        
 
282
                                                strptime(buf, "%a, %d %b %Y %H:%M:%S GMT", &tm);
 
283
                                                t_header = mktime(&tm);
 
284
                                                        
 
285
                                                strptime(mtime->ptr, "%a, %d %b %Y %H:%M:%S GMT", &tm);
 
286
                                                t_file = mktime(&tm);
 
287
 
 
288
                                                if (t_file > t_header) return HANDLER_GO_ON;
 
289
        
 
290
                                                con->http_status = 304;
 
291
                                                return HANDLER_FINISHED;
292
292
                                        }
293
293
                                } else {
294
294
                                        con->http_status = 304;
302
302
        } else if (con->request.http_if_modified_since) {
303
303
                size_t used_len;
304
304
                char *semicolon;
305
 
                
 
305
 
306
306
                if (NULL == (semicolon = strchr(con->request.http_if_modified_since, ';'))) {
307
307
                        used_len = strlen(con->request.http_if_modified_since);
308
308
                } else {
312
312
                if (0 == strncmp(con->request.http_if_modified_since, mtime->ptr, used_len)) {
313
313
                        con->http_status = 304;
314
314
                        return HANDLER_FINISHED;
 
315
                } else {
 
316
                        char buf[sizeof("Sat, 23 Jul 2005 21:20:01 GMT")];
 
317
                        time_t t_header, t_file;
 
318
                        struct tm tm;
 
319
 
 
320
                        /* convert to timestamp */
 
321
                        if (used_len >= sizeof(buf)) return HANDLER_GO_ON;
 
322
 
 
323
                        strncpy(buf, con->request.http_if_modified_since, used_len);
 
324
                        buf[used_len] = '\0';
 
325
                                        
 
326
                        strptime(buf, "%a, %d %b %Y %H:%M:%S GMT", &tm);
 
327
                        t_header = mktime(&tm);
 
328
                                                        
 
329
                        strptime(mtime->ptr, "%a, %d %b %Y %H:%M:%S GMT", &tm);
 
330
                        t_file = mktime(&tm);
 
331
 
 
332
                        if (t_file > t_header) return HANDLER_GO_ON;
 
333
 
 
334
                        con->http_status = 304;
 
335
                        return HANDLER_FINISHED;
315
336
                }
316
337
        }
317
338