webfs: make up fake spoof referer
This commit is contained in:
parent
37606a6b29
commit
dd04c51470
1 changed files with 21 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue