Fossil SCM
For a 304 HTTP response, omit extraneous fields such as Content-Type and ETag.
Commit
6624350b0e3056649643d0d2f0b3e20703f95031809350ac4b0fce69f9fed7be
Parent
972341dbca1844b…
1 file changed
+4
-1
+4
-1
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -289,10 +289,11 @@ | ||
| 289 | 289 | fprintf(g.httpOut, "X-UA-Compatible: IE=edge\r\n"); |
| 290 | 290 | }else{ |
| 291 | 291 | assert( rangeEnd==0 ); |
| 292 | 292 | fprintf(g.httpOut, "Status: %d %s\r\n", iReplyStatus, zReplyStatus); |
| 293 | 293 | } |
| 294 | + if( iReplyStatus==304 ) goto finish_cgi_reply; | |
| 294 | 295 | if( g.isConst ){ |
| 295 | 296 | /* isConst means that the reply is guaranteed to be invariant, even |
| 296 | 297 | ** after configuration changes and/or Fossil binary recompiles. */ |
| 297 | 298 | fprintf(g.httpOut, "Cache-Control: max-age=31536000\r\n"); |
| 298 | 299 | }else if( etag_tag()!=0 ){ |
| @@ -359,11 +360,12 @@ | ||
| 359 | 360 | fprintf(g.httpOut, "Content-Length: %d\r\n", total_size); |
| 360 | 361 | }else{ |
| 361 | 362 | total_size = 0; |
| 362 | 363 | } |
| 363 | 364 | fprintf(g.httpOut, "\r\n"); |
| 364 | - if( total_size>0 && iReplyStatus != 304 | |
| 365 | + if( total_size>0 | |
| 366 | + && iReplyStatus!=304 | |
| 365 | 367 | && fossil_strcmp(P("REQUEST_METHOD"),"HEAD")!=0 |
| 366 | 368 | ){ |
| 367 | 369 | int i, size; |
| 368 | 370 | for(i=0; i<2; i++){ |
| 369 | 371 | size = blob_size(&cgiContent[i]); |
| @@ -378,10 +380,11 @@ | ||
| 378 | 380 | rangeStart = 0; |
| 379 | 381 | total_size -= n; |
| 380 | 382 | } |
| 381 | 383 | } |
| 382 | 384 | } |
| 385 | +finish_cgi_reply: | |
| 383 | 386 | fflush(g.httpOut); |
| 384 | 387 | CGIDEBUG(("-------- END cgi ---------\n")); |
| 385 | 388 | |
| 386 | 389 | /* After the webpage has been sent, do any useful background |
| 387 | 390 | ** processing. |
| 388 | 391 |
| --- 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 |