ref: 026c679f49ca89b7585d3ee3364d154c2b00cc3a
parent: 6b9cc409de48052e4474150236a22a4b6b44fceb
author: mischief <[email protected]>
date: Tue Sep 18 09:14:00 EDT 2018
webfs: remove automatic Referer header automatic Referer headers were found to break downloads from sourceforge.net, causing html pages to appear instead of tarballs. if a website does need them, they can be added as needed via hget's -r flag, or added to mothra. reverts commits 67f536d20329 and 6d999c39a9f0
--- a/sys/src/cmd/webfs/fs.c
+++ b/sys/src/cmd/webfs/fs.c
@@ -407,33 +407,6 @@
if(!lookkey(cl->hdr, "Accept"))
cl->hdr = addkey(cl->hdr, "Accept", "*/*");
- if(!lookkey(cl->hdr, "Referer")){
- char *r;
- Url *u;
-
- /*
- * Referer header is often required on broken
- * websites even if the spec makes them optional,
- * so we make one up.
- */
- if(u = url("/", cl->url)){
- if(r = u->host){
- u->host = smprint("%N", r);
- free(r);
- }
-
- /* do not send credentials */
- free(u->user); u->user = nil;
- free(u->pass); u->pass = nil;
-
- if(r = smprint("%U", u)){
- cl->hdr = addkey(cl->hdr, "Referer", r);
- free(r);
- }
- freeurl(u);
- }
- }
-
if(!lookkey(cl->hdr, "Connection"))
cl->hdr = addkey(cl->hdr, "Connection", "keep-alive");