Changeset 5214 for trunk/oscam-http-helpers.c
- Timestamp:
- 05/10/11 01:20:32 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/oscam-http-helpers.c
r5213 r5214 469 469 } 470 470 471 472 471 void send_headers(FILE *f, int32_t status, char *title, char *extra, char *mime, int32_t cache, int32_t length, char *content, int8_t forcePlain){ 473 472 time_t now; … … 512 511 char buf[(2* strlen(title)) + strlen(text) + 128]; 513 512 char *pos = buf; 514 send_headers(f, status, title, extra, "text/html", 0, strlen(buf), NULL, forcePlain);515 513 pos += snprintf(pos, sizeof(buf)-(pos-buf), "<HTML><HEAD><TITLE>%d %s</TITLE></HEAD>\r\n", status, title); 516 514 pos += snprintf(pos, sizeof(buf)-(pos-buf), "<BODY><H4>%d %s</H4>\r\n", status, title); 517 515 pos += snprintf(pos, sizeof(buf)-(pos-buf), "%s\r\n", text); 518 516 pos += snprintf(pos, sizeof(buf)-(pos-buf), "</BODY></HTML>\r\n"); 517 send_headers(f, status, title, extra, "text/html", 0, strlen(buf), NULL, forcePlain); 519 518 if(forcePlain == 1) fwrite(buf, 1, strlen(buf), f); 520 519 else webif_write(buf, f); … … 523 522 void send_error500(FILE *f){ 524 523 send_error(f, 500, "Internal Server Error", NULL, "The server encountered an internal error that prevented it from fulfilling this request.", 0); 524 } 525 526 void send_header304(FILE *f){ 527 send_headers(f, 304, "Not Modified", NULL, NULL, 1, 0, NULL, 0); 525 528 } 526 529 … … 551 554 stat(filename, &st); 552 555 moddate = st.st_mtime; 556 if(moddate < modifiedheader){ 557 send_header304(f); 558 return; 559 } 553 560 if((fp = fopen(filename, "r"))==NULL) return; 554 561 if(!cs_malloc(&result, st.st_size + 1, -1)){ … … 575 582 } 576 583 if(moddate < modifiedheader || (uint32_t)crc32(0L, (uchar *)result, strlen(result)) == etagheader){ 577 send_header s(f, 304, "Not Modified", NULL, NULL, 1, strlen(result), result, 0);584 send_header304(f); 578 585 } else { 579 586 send_headers(f, 200, "OK", NULL, mimetype, 1, strlen(result), result, 0);
Note:
See TracChangeset
for help on using the changeset viewer.