Fossil SCM

For a 304 HTTP response, omit extraneous fields such as Content-Type and ETag.

drh 2020-05-09 20:59 trunk
Commit 6624350b0e3056649643d0d2f0b3e20703f95031809350ac4b0fce69f9fed7be
1 file changed +4 -1
+4 -1
--- src/cgi.c
+++ src/cgi.c
@@ -289,10 +289,11 @@
289289
fprintf(g.httpOut, "X-UA-Compatible: IE=edge\r\n");
290290
}else{
291291
assert( rangeEnd==0 );
292292
fprintf(g.httpOut, "Status: %d %s\r\n", iReplyStatus, zReplyStatus);
293293
}
294
+ if( iReplyStatus==304 ) goto finish_cgi_reply;
294295
if( g.isConst ){
295296
/* isConst means that the reply is guaranteed to be invariant, even
296297
** after configuration changes and/or Fossil binary recompiles. */
297298
fprintf(g.httpOut, "Cache-Control: max-age=31536000\r\n");
298299
}else if( etag_tag()!=0 ){
@@ -359,11 +360,12 @@
359360
fprintf(g.httpOut, "Content-Length: %d\r\n", total_size);
360361
}else{
361362
total_size = 0;
362363
}
363364
fprintf(g.httpOut, "\r\n");
364
- if( total_size>0 && iReplyStatus != 304
365
+ if( total_size>0
366
+ && iReplyStatus!=304
365367
&& fossil_strcmp(P("REQUEST_METHOD"),"HEAD")!=0
366368
){
367369
int i, size;
368370
for(i=0; i<2; i++){
369371
size = blob_size(&cgiContent[i]);
@@ -378,10 +380,11 @@
378380
rangeStart = 0;
379381
total_size -= n;
380382
}
381383
}
382384
}
385
+finish_cgi_reply:
383386
fflush(g.httpOut);
384387
CGIDEBUG(("-------- END cgi ---------\n"));
385388
386389
/* After the webpage has been sent, do any useful background
387390
** processing.
388391
--- src/cgi.c
+++ src/cgi.c
@@ -289,10 +289,11 @@
289 fprintf(g.httpOut, "X-UA-Compatible: IE=edge\r\n");
290 }else{
291 assert( rangeEnd==0 );
292 fprintf(g.httpOut, "Status: %d %s\r\n", iReplyStatus, zReplyStatus);
293 }
 
294 if( g.isConst ){
295 /* isConst means that the reply is guaranteed to be invariant, even
296 ** after configuration changes and/or Fossil binary recompiles. */
297 fprintf(g.httpOut, "Cache-Control: max-age=31536000\r\n");
298 }else if( etag_tag()!=0 ){
@@ -359,11 +360,12 @@
359 fprintf(g.httpOut, "Content-Length: %d\r\n", total_size);
360 }else{
361 total_size = 0;
362 }
363 fprintf(g.httpOut, "\r\n");
364 if( total_size>0 && iReplyStatus != 304
 
365 && fossil_strcmp(P("REQUEST_METHOD"),"HEAD")!=0
366 ){
367 int i, size;
368 for(i=0; i<2; i++){
369 size = blob_size(&cgiContent[i]);
@@ -378,10 +380,11 @@
378 rangeStart = 0;
379 total_size -= n;
380 }
381 }
382 }
 
383 fflush(g.httpOut);
384 CGIDEBUG(("-------- END cgi ---------\n"));
385
386 /* After the webpage has been sent, do any useful background
387 ** processing.
388
--- src/cgi.c
+++ src/cgi.c
@@ -289,10 +289,11 @@
289 fprintf(g.httpOut, "X-UA-Compatible: IE=edge\r\n");
290 }else{
291 assert( rangeEnd==0 );
292 fprintf(g.httpOut, "Status: %d %s\r\n", iReplyStatus, zReplyStatus);
293 }
294 if( iReplyStatus==304 ) goto finish_cgi_reply;
295 if( g.isConst ){
296 /* isConst means that the reply is guaranteed to be invariant, even
297 ** after configuration changes and/or Fossil binary recompiles. */
298 fprintf(g.httpOut, "Cache-Control: max-age=31536000\r\n");
299 }else if( etag_tag()!=0 ){
@@ -359,11 +360,12 @@
360 fprintf(g.httpOut, "Content-Length: %d\r\n", total_size);
361 }else{
362 total_size = 0;
363 }
364 fprintf(g.httpOut, "\r\n");
365 if( total_size>0
366 && iReplyStatus!=304
367 && fossil_strcmp(P("REQUEST_METHOD"),"HEAD")!=0
368 ){
369 int i, size;
370 for(i=0; i<2; i++){
371 size = blob_size(&cgiContent[i]);
@@ -378,10 +380,11 @@
380 rangeStart = 0;
381 total_size -= n;
382 }
383 }
384 }
385 finish_cgi_reply:
386 fflush(g.httpOut);
387 CGIDEBUG(("-------- END cgi ---------\n"));
388
389 /* After the webpage has been sent, do any useful background
390 ** processing.
391

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button