Fossil SCM

Reordered /builtin a bit to allow it to respond with a 304 *without* generating extraneous output if etag_check() says it can.

stephan 2020-07-31 17:31 ajax-wiki-editor
Commit 8c9ea224194389c541ecd6f985a4994a8dd62e29afc883d98a44c3f077be24be
1 file changed +16 -17
+16 -17
--- src/style.c
+++ src/style.c
@@ -1186,46 +1186,45 @@
11861186
** URL: builtin/FILENAME
11871187
**
11881188
** Return the built-in text given by FILENAME. This is used internally
11891189
** by many Fossil web pages to load built-in javascript files.
11901190
**
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).
11941194
*/
11951195
void page_builtin_text(void){
11961196
Blob out;
11971197
const char *zName = P("name");
11981198
const char *zTxt = 0;
1199
- const char *zId = PD("id",P("cache"));
1199
+ const char *zId = P("id");
12001200
int nId;
12011201
int isBundle = 0;
12021202
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
+ }
12031208
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
+ }
12041214
if(':'==zName[0]){
12051215
isBundle = 1;
12061216
zTxt = page_builtin_text_bundle(zName+1) ? "" : NULL;
12071217
}else{
12081218
zTxt = builtin_text(zName);
12091219
}
12101220
}
12111221
if( zTxt==0 ){
1222
+ cgi_set_content_type("text/html");
12121223
cgi_set_status(404, "Not Found");
12131224
@ 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){
12271226
blob_init(&out, zTxt, -1);
12281227
cgi_set_content(&out);
12291228
}
12301229
}
12311230
12321231
--- 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

Keyboard Shortcuts

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