Index: fetch/fetch.1 =================================================================== RCS file: /home/ncvs/src/usr.bin/fetch/fetch.1,v retrieving revision 1.66 diff -u -r1.66 fetch.1 --- fetch/fetch.1 13 Feb 2005 22:25:21 -0000 1.66 +++ fetch/fetch.1 15 Apr 2005 14:18:01 -0000 @@ -92,6 +92,10 @@ only. .It Fl d Use a direct connection even if a proxy is configured. +.It Fl e Ar URL +Specifies the referrer +.Ar URL +to use for HTTP requests. .It Fl F In combination with the .Fl r Index: fetch/fetch.c =================================================================== RCS file: /home/ncvs/src/usr.bin/fetch/fetch.c,v retrieving revision 1.75 diff -u -r1.75 fetch.c --- fetch/fetch.c 18 Nov 2004 12:01:30 -0000 1.75 +++ fetch/fetch.c 15 Apr 2005 14:18:01 -0000 @@ -57,6 +57,7 @@ int b_flag; /*! -b: workaround TCP bug */ char *c_dirname; /* -c: remote directory */ int d_flag; /* -d: direct connection */ +char *e_refer; /* -e: HTTP refer */ int F_flag; /* -F: restart without checking mtime */ char *f_filename; /* -f: file to fetch */ char *h_hostname; /* -h: host to fetch from */ @@ -376,12 +377,15 @@ strcat(flags, "d"); if (A_flag) strcat(flags, "A"); + if (e_refer) + url->refer = e_refer; timeout = T_secs ? T_secs : http_timeout; } /* set the protocol timeout. */ fetchTimeout = timeout; + /* just print size */ if (s_flag) { if (timeout) @@ -705,7 +709,7 @@ usage(void) { fprintf(stderr, "%s\n%s\n%s\n", - "usage: fetch [-146AFMPRUadlmnpqrsv] [-N netrc] [-o outputfile]", + "usage: fetch [-146AFMPRUadlmnpqrsv] [-N netrc] [-e refer] [-o outputfile]", " [-S bytes] [-B bytes] [-T seconds] [-w seconds]", " [-h host -f file [-c dir] | URL ...]"); } @@ -724,7 +728,7 @@ int c, e, r; while ((c = getopt(argc, argv, - "146AaB:bc:dFf:Hh:lMmN:nPpo:qRrS:sT:tUvw:")) != -1) + "146AaB:bc:de:Ff:Hh:lMmN:nPpo:qRrS:sT:tUvw:")) != -1) switch (c) { case '1': once_flag = 1; @@ -756,6 +760,9 @@ case 'd': d_flag = 1; break; + case 'e': + e_refer = optarg; + break; case 'F': F_flag = 1; break; Index: libfetch/fetch.3 =================================================================== RCS file: /home/ncvs/src/lib/libfetch/fetch.3,v retrieving revision 1.60 diff -u -r1.60 fetch.3 --- libfetch/fetch.3 13 Feb 2005 23:45:47 -0000 1.60 +++ libfetch/fetch.3 15 Apr 2005 14:18:05 -0000 @@ -161,6 +161,7 @@ char user[URL_USERLEN+1]; char pwd[URL_PWDLEN+1]; char host[MAXHOSTNAMELEN+1]; + char *refer; int port; char *doc; off_t offset; Index: libfetch/fetch.h =================================================================== RCS file: /home/ncvs/src/lib/libfetch/fetch.h,v retrieving revision 1.26 diff -u -r1.26 fetch.h --- libfetch/fetch.h 21 Sep 2004 18:35:20 -0000 1.26 +++ libfetch/fetch.h 15 Apr 2005 14:18:05 -0000 @@ -42,6 +42,7 @@ char user[URL_USERLEN+1]; char pwd[URL_PWDLEN+1]; char host[MAXHOSTNAMELEN+1]; + char *refer; int port; char *doc; off_t offset; Index: libfetch/http.c =================================================================== RCS file: /home/ncvs/src/lib/libfetch/http.c,v retrieving revision 1.76 diff -u -r1.76 http.c --- libfetch/http.c 2 Mar 2005 19:09:28 -0000 1.76 +++ libfetch/http.c 15 Apr 2005 14:18:05 -0000 @@ -898,7 +898,9 @@ } /* other headers */ - if ((p = getenv("HTTP_REFERER")) != NULL && *p != '\0') { + if (url->refer) + _http_cmd(conn, "Referer: %s", url->refer); + else if ((p = getenv("HTTP_REFERER")) != NULL && *p != '\0') { if (strcasecmp(p, "auto") == 0) _http_cmd(conn, "Referer: %s://%s%s", url->scheme, host, url->doc);