From dd04c514700c8227d5d7c0a8eb84b3d8680b2f9c Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Tue, 3 Apr 2012 08:32:21 +0200 Subject: [PATCH] webfs: make up fake spoof referer --- sys/src/cmd/webfs/fs.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sys/src/cmd/webfs/fs.c b/sys/src/cmd/webfs/fs.c index b331819a4..7f8530434 100644 --- a/sys/src/cmd/webfs/fs.c +++ b/sys/src/cmd/webfs/fs.c @@ -397,10 +397,31 @@ fsopen(Req *r) m = "GET"; if(cl->request[0]) m = cl->request; + + 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 = 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"); + if(agent && !lookkey(cl->hdr, "User-Agent")) cl->hdr = addkey(cl->hdr, "User-Agent", agent); + http(m, cl->url, cl->hdr, cl->qbody, f->buq); cl->request[0] = 0; cl->url = nil;