| | @@ -69,10 +69,11 @@ |
| 69 | 69 | #endif |
| 70 | 70 | |
| 71 | 71 | static char zETag[33]; /* The generated ETag */ |
| 72 | 72 | static int iMaxAge = 0; /* The max-age parameter in the reply */ |
| 73 | 73 | static sqlite3_int64 iEtagMtime = 0; /* Last-Modified time */ |
| 74 | +static int etagCancelled = 0; /* Never send an etag */ |
| 74 | 75 | |
| 75 | 76 | /* |
| 76 | 77 | ** Return a hash that changes every time the Fossil source code is |
| 77 | 78 | ** rebuilt. |
| 78 | 79 | ** |
| | @@ -95,10 +96,11 @@ |
| 95 | 96 | void etag_check(unsigned eFlags, const char *zHash){ |
| 96 | 97 | const char *zIfNoneMatch; |
| 97 | 98 | char zBuf[50]; |
| 98 | 99 | assert( zETag[0]==0 ); /* Only call this routine once! */ |
| 99 | 100 | |
| 101 | + if( etagCancelled ) return; |
| 100 | 102 | iMaxAge = 86400; |
| 101 | 103 | md5sum_init(); |
| 102 | 104 | |
| 103 | 105 | /* Always include the executable ID as part of the hash */ |
| 104 | 106 | md5sum_step_text("exe-id: ", -1); |
| | @@ -108,18 +110,20 @@ |
| 108 | 110 | if( (eFlags & ETAG_HASH)!=0 && zHash ){ |
| 109 | 111 | md5sum_step_text("hash: ", -1); |
| 110 | 112 | md5sum_step_text(zHash, -1); |
| 111 | 113 | md5sum_step_text("\n", 1); |
| 112 | 114 | iMaxAge = 0; |
| 113 | | - }else if( eFlags & ETAG_DATA ){ |
| 115 | + } |
| 116 | + if( eFlags & ETAG_DATA ){ |
| 114 | 117 | int iKey = db_int(0, "SELECT max(rcvid) FROM rcvfrom"); |
| 115 | 118 | sqlite3_snprintf(sizeof(zBuf),zBuf,"%d",iKey); |
| 116 | 119 | md5sum_step_text("data: ", -1); |
| 117 | 120 | md5sum_step_text(zBuf, -1); |
| 118 | 121 | md5sum_step_text("\n", 1); |
| 119 | 122 | iMaxAge = 60; |
| 120 | | - }else if( eFlags & ETAG_CONFIG ){ |
| 123 | + } |
| 124 | + if( eFlags & ETAG_CONFIG ){ |
| 121 | 125 | int iKey = db_int(0, "SELECT value FROM config WHERE name='cfgcnt'"); |
| 122 | 126 | sqlite3_snprintf(sizeof(zBuf),zBuf,"%d",iKey); |
| 123 | 127 | md5sum_step_text("config: ", -1); |
| 124 | 128 | md5sum_step_text(zBuf, -1); |
| 125 | 129 | md5sum_step_text("\n", 1); |
| | @@ -245,5 +249,13 @@ |
| 245 | 249 | zHash = find_option("hash",0,1); |
| 246 | 250 | if( zKey ) iKey = atoi(zKey); |
| 247 | 251 | etag_check(iKey, zHash); |
| 248 | 252 | fossil_print("%s\n", etag_tag()); |
| 249 | 253 | } |
| 254 | + |
| 255 | +/* |
| 256 | +** Cancel the ETag. |
| 257 | +*/ |
| 258 | +void etag_cancel(void){ |
| 259 | + etagCancelled = 1; |
| 260 | + zETag[0] = 0; |
| 261 | +} |
| 250 | 262 | |