| | @@ -173,10 +173,26 @@ |
| 173 | 173 | cgi_set_status(304, "Not Modified"); |
| 174 | 174 | cgi_reply(); |
| 175 | 175 | db_close(0); |
| 176 | 176 | fossil_exit(0); |
| 177 | 177 | } |
| 178 | + |
| 179 | +/* |
| 180 | +** If the output is determined purely by hash parameter and the hash |
| 181 | +** is long enough to be invariant, then set the g.isConst flag, indicating |
| 182 | +** that the output will never change. |
| 183 | +*/ |
| 184 | +void etag_check_for_invariant_name(const char *zHash){ |
| 185 | + size_t nHash = strlen(zHash); |
| 186 | + if( nHash<HNAME_MIN ){ |
| 187 | + return; /* Name is too short */ |
| 188 | + } |
| 189 | + if( !validate16(zHash, (int)nHash) ){ |
| 190 | + return; /* Name is not pure hex */ |
| 191 | + } |
| 192 | + g.isConst = 1; /* A long hex identifier must be a unique hash */ |
| 193 | +} |
| 178 | 194 | |
| 179 | 195 | /* |
| 180 | 196 | ** Accept a new Last-Modified time. This routine should be called by |
| 181 | 197 | ** page generators that know a valid last-modified time. This routine |
| 182 | 198 | ** might generate a 304 Not Modified reply and exit(), never returning. |
| | @@ -212,11 +228,11 @@ |
| 212 | 228 | } |
| 213 | 229 | |
| 214 | 230 | /* Return the ETag, if there is one. |
| 215 | 231 | */ |
| 216 | 232 | const char *etag_tag(void){ |
| 217 | | - return zETag; |
| 233 | + return g.isConst ? "" : zETag; |
| 218 | 234 | } |
| 219 | 235 | |
| 220 | 236 | /* Return the recommended max-age |
| 221 | 237 | */ |
| 222 | 238 | int etag_maxage(void){ |
| 223 | 239 | |