Fossil SCM

Have the "raw" webpage try to guess the filename and the mimetype of the artifact being downloaded, if the m= query parameter is omitted.

drh 2012-08-13 16:18 trunk
Commit af16836c23b4af75986448f16fe3eb4990a89ecc
1 file changed +8 -1
+8 -1
--- src/info.c
+++ src/info.c
@@ -1205,14 +1205,21 @@
12051205
int rid;
12061206
const char *zMime;
12071207
Blob content;
12081208
12091209
rid = name_to_rid_www("name");
1210
- zMime = PD("m","application/x-fossil-artifact");
12111210
login_check_credentials();
12121211
if( !g.perm.Read ){ login_needed(); return; }
12131212
if( rid==0 ) fossil_redirect_home();
1213
+ zMime = P("m");
1214
+ if( zMime==0 ){
1215
+ char *zFName = db_text(0, "SELECT filename.name FROM mlink, filename"
1216
+ " WHERE mlink.fid=%d"
1217
+ " AND filename.fnid=mlink.fnid", rid);
1218
+ if( zFName ) zMime = mimetype_from_name(zFName);
1219
+ if( zMime==0 ) zMime = "application/x-fossil-artifact";
1220
+ }
12141221
content_get(rid, &content);
12151222
cgi_set_content_type(zMime);
12161223
cgi_set_content(&content);
12171224
}
12181225
12191226
--- src/info.c
+++ src/info.c
@@ -1205,14 +1205,21 @@
1205 int rid;
1206 const char *zMime;
1207 Blob content;
1208
1209 rid = name_to_rid_www("name");
1210 zMime = PD("m","application/x-fossil-artifact");
1211 login_check_credentials();
1212 if( !g.perm.Read ){ login_needed(); return; }
1213 if( rid==0 ) fossil_redirect_home();
 
 
 
 
 
 
 
 
1214 content_get(rid, &content);
1215 cgi_set_content_type(zMime);
1216 cgi_set_content(&content);
1217 }
1218
1219
--- src/info.c
+++ src/info.c
@@ -1205,14 +1205,21 @@
1205 int rid;
1206 const char *zMime;
1207 Blob content;
1208
1209 rid = name_to_rid_www("name");
 
1210 login_check_credentials();
1211 if( !g.perm.Read ){ login_needed(); return; }
1212 if( rid==0 ) fossil_redirect_home();
1213 zMime = P("m");
1214 if( zMime==0 ){
1215 char *zFName = db_text(0, "SELECT filename.name FROM mlink, filename"
1216 " WHERE mlink.fid=%d"
1217 " AND filename.fnid=mlink.fnid", rid);
1218 if( zFName ) zMime = mimetype_from_name(zFName);
1219 if( zMime==0 ) zMime = "application/x-fossil-artifact";
1220 }
1221 content_get(rid, &content);
1222 cgi_set_content_type(zMime);
1223 cgi_set_content(&content);
1224 }
1225
1226

Keyboard Shortcuts

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