Fossil SCM
Reordered /builtin a bit to allow it to respond with a 304 *without* generating extraneous output if etag_check() says it can.
Commit
8c9ea224194389c541ecd6f985a4994a8dd62e29afc883d98a44c3f077be24be
Parent
41ce65fc31eb6da…
1 file changed
+16
-17
+16
-17
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -1186,46 +1186,45 @@ | ||
| 1186 | 1186 | ** URL: builtin/FILENAME |
| 1187 | 1187 | ** |
| 1188 | 1188 | ** Return the built-in text given by FILENAME. This is used internally |
| 1189 | 1189 | ** by many Fossil web pages to load built-in javascript files. |
| 1190 | 1190 | ** |
| 1191 | -** If the id= or cache= query parameter is present, then Fossil | |
| 1192 | -** assumes that the result is immutable and sets a very large cache | |
| 1193 | -** retention time (1 year). | |
| 1191 | +** If the id= parameter is present, then Fossil assumes that the | |
| 1192 | +** result is immutable and sets a very large cache retention time (1 | |
| 1193 | +** year). | |
| 1194 | 1194 | */ |
| 1195 | 1195 | void page_builtin_text(void){ |
| 1196 | 1196 | Blob out; |
| 1197 | 1197 | const char *zName = P("name"); |
| 1198 | 1198 | const char *zTxt = 0; |
| 1199 | - const char *zId = PD("id",P("cache")); | |
| 1199 | + const char *zId = P("id"); | |
| 1200 | 1200 | int nId; |
| 1201 | 1201 | int isBundle = 0; |
| 1202 | 1202 | |
| 1203 | + if( zId && (nId = (int)strlen(zId))>=8 && strncmp(zId,MANIFEST_UUID,nId)==0 ){ | |
| 1204 | + g.isConst = 1; | |
| 1205 | + }else{ | |
| 1206 | + etag_check(0,0)/*might not return*/; | |
| 1207 | + } | |
| 1203 | 1208 | if( zName ){ |
| 1209 | + if( sqlite3_strglob("*.js", zName)==0 ){ | |
| 1210 | + cgi_set_content_type("application/javascript"); | |
| 1211 | + }else{ | |
| 1212 | + cgi_set_content_type("text/plain"); | |
| 1213 | + } | |
| 1204 | 1214 | if(':'==zName[0]){ |
| 1205 | 1215 | isBundle = 1; |
| 1206 | 1216 | zTxt = page_builtin_text_bundle(zName+1) ? "" : NULL; |
| 1207 | 1217 | }else{ |
| 1208 | 1218 | zTxt = builtin_text(zName); |
| 1209 | 1219 | } |
| 1210 | 1220 | } |
| 1211 | 1221 | if( zTxt==0 ){ |
| 1222 | + cgi_set_content_type("text/html"); | |
| 1212 | 1223 | cgi_set_status(404, "Not Found"); |
| 1213 | 1224 | @ File "%h(zName)" not found |
| 1214 | - return; | |
| 1215 | - } | |
| 1216 | - if( sqlite3_strglob("*.js", zName)==0 ){ | |
| 1217 | - cgi_set_content_type("application/javascript"); | |
| 1218 | - }else{ | |
| 1219 | - cgi_set_content_type("text/plain"); | |
| 1220 | - } | |
| 1221 | - if( zId && (nId = (int)strlen(zId))>=8 && strncmp(zId,MANIFEST_UUID,nId)==0 ){ | |
| 1222 | - g.isConst = 1; | |
| 1223 | - }else{ | |
| 1224 | - etag_check(0,0); | |
| 1225 | - } | |
| 1226 | - if(isBundle==0){ | |
| 1225 | + }else if(isBundle==0){ | |
| 1227 | 1226 | blob_init(&out, zTxt, -1); |
| 1228 | 1227 | cgi_set_content(&out); |
| 1229 | 1228 | } |
| 1230 | 1229 | } |
| 1231 | 1230 | |
| 1232 | 1231 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -1186,46 +1186,45 @@ | |
| 1186 | ** URL: builtin/FILENAME |
| 1187 | ** |
| 1188 | ** Return the built-in text given by FILENAME. This is used internally |
| 1189 | ** by many Fossil web pages to load built-in javascript files. |
| 1190 | ** |
| 1191 | ** If the id= or cache= query parameter is present, then Fossil |
| 1192 | ** assumes that the result is immutable and sets a very large cache |
| 1193 | ** retention time (1 year). |
| 1194 | */ |
| 1195 | void page_builtin_text(void){ |
| 1196 | Blob out; |
| 1197 | const char *zName = P("name"); |
| 1198 | const char *zTxt = 0; |
| 1199 | const char *zId = PD("id",P("cache")); |
| 1200 | int nId; |
| 1201 | int isBundle = 0; |
| 1202 | |
| 1203 | if( zName ){ |
| 1204 | if(':'==zName[0]){ |
| 1205 | isBundle = 1; |
| 1206 | zTxt = page_builtin_text_bundle(zName+1) ? "" : NULL; |
| 1207 | }else{ |
| 1208 | zTxt = builtin_text(zName); |
| 1209 | } |
| 1210 | } |
| 1211 | if( zTxt==0 ){ |
| 1212 | cgi_set_status(404, "Not Found"); |
| 1213 | @ File "%h(zName)" not found |
| 1214 | return; |
| 1215 | } |
| 1216 | if( sqlite3_strglob("*.js", zName)==0 ){ |
| 1217 | cgi_set_content_type("application/javascript"); |
| 1218 | }else{ |
| 1219 | cgi_set_content_type("text/plain"); |
| 1220 | } |
| 1221 | if( zId && (nId = (int)strlen(zId))>=8 && strncmp(zId,MANIFEST_UUID,nId)==0 ){ |
| 1222 | g.isConst = 1; |
| 1223 | }else{ |
| 1224 | etag_check(0,0); |
| 1225 | } |
| 1226 | if(isBundle==0){ |
| 1227 | blob_init(&out, zTxt, -1); |
| 1228 | cgi_set_content(&out); |
| 1229 | } |
| 1230 | } |
| 1231 | |
| 1232 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -1186,46 +1186,45 @@ | |
| 1186 | ** URL: builtin/FILENAME |
| 1187 | ** |
| 1188 | ** Return the built-in text given by FILENAME. This is used internally |
| 1189 | ** by many Fossil web pages to load built-in javascript files. |
| 1190 | ** |
| 1191 | ** If the id= parameter is present, then Fossil assumes that the |
| 1192 | ** result is immutable and sets a very large cache retention time (1 |
| 1193 | ** year). |
| 1194 | */ |
| 1195 | void page_builtin_text(void){ |
| 1196 | Blob out; |
| 1197 | const char *zName = P("name"); |
| 1198 | const char *zTxt = 0; |
| 1199 | const char *zId = P("id"); |
| 1200 | int nId; |
| 1201 | int isBundle = 0; |
| 1202 | |
| 1203 | if( zId && (nId = (int)strlen(zId))>=8 && strncmp(zId,MANIFEST_UUID,nId)==0 ){ |
| 1204 | g.isConst = 1; |
| 1205 | }else{ |
| 1206 | etag_check(0,0)/*might not return*/; |
| 1207 | } |
| 1208 | if( zName ){ |
| 1209 | if( sqlite3_strglob("*.js", zName)==0 ){ |
| 1210 | cgi_set_content_type("application/javascript"); |
| 1211 | }else{ |
| 1212 | cgi_set_content_type("text/plain"); |
| 1213 | } |
| 1214 | if(':'==zName[0]){ |
| 1215 | isBundle = 1; |
| 1216 | zTxt = page_builtin_text_bundle(zName+1) ? "" : NULL; |
| 1217 | }else{ |
| 1218 | zTxt = builtin_text(zName); |
| 1219 | } |
| 1220 | } |
| 1221 | if( zTxt==0 ){ |
| 1222 | cgi_set_content_type("text/html"); |
| 1223 | cgi_set_status(404, "Not Found"); |
| 1224 | @ File "%h(zName)" not found |
| 1225 | }else if(isBundle==0){ |
| 1226 | blob_init(&out, zTxt, -1); |
| 1227 | cgi_set_content(&out); |
| 1228 | } |
| 1229 | } |
| 1230 | |
| 1231 |