Added an option to hget for sending raw http headers; useful for faking referers on misbehaving web sites. Reference: /n/sources/patch/applied/hget-raw-hdr Date: Thu Aug 6 01:25:10 CES 2009 Signed-off-by: 23hiro@gmail.com --- /sys/man/1/hget Thu Aug 6 01:24:46 2009 +++ /sys/man/1/hget Thu Aug 6 01:24:43 2009 @@ -15,6 +15,9 @@ ][ .B -x .I netmntpt +][ +.B -r +.I header ] .I url .SH DESCRIPTION @@ -48,6 +51,10 @@ .B -h causes HTTP headers to be printed to standard output in addition to the transferred web page. +.PP +Option +.B -r +can be used to send an arbitrary HTTP header. .PP Option .B -d --- /sys/src/cmd/hget.c Thu Aug 6 01:24:54 2009 +++ /sys/src/cmd/hget.c Thu Aug 6 01:24:49 2009 @@ -17,6 +17,7 @@ char *redirect; char *postbody; char *cred; + char *rhead; long mtime; }; @@ -92,7 +93,7 @@ void usage(void) { - fprint(2, "usage: %s [-dhv] [-o outfile] [-p body] [-x netmtpt] url\n", argv0); + fprint(2, "usage: %s [-dhv] [-o outfile] [-p body] [-x netmtpt] [-r header] url\n", argv0); exits("usage"); } @@ -134,6 +135,9 @@ case 'x': net = EARGF(usage()); break; + case 'r': + u.rhead = EARGF(usage()); + break; case 'p': t = EARGF(usage()); if(p != postbody) @@ -379,9 +383,6 @@ "Pragma: no-cache\r\n", u->host, u->page, u->host); } - if(u->cred) - dfprint(fd, "Authorization: Basic %s\r\n", - u->cred); } else { dfprint(fd, "POST %s HTTP/1.0\r\n" "Host: %s\r\n" @@ -389,9 +390,11 @@ "Content-length: %d\r\n" "User-agent: Plan9/hget\r\n", u->page, u->host, strlen(u->postbody)); - if(u->cred) - dfprint(fd, "Authorization: Basic %s\r\n", u->cred); } + if(u->cred) + dfprint(fd, "Authorization: Basic %s\r\n", u->cred); + if(u->rhead) + dfprint(fd, "%s\r\n", u->rhead); if(r->start != 0){ dfprint(fd, "Range: bytes=%d-\n", r->start); if(u->etag != nil){