Dear wget author(s):
I have added a feature to wget so that it can set a Referer: header
explicitly. This is useful when a object requires a specific Referer:
information to be retrieved successfully. I have attached a patch to
wget 1.53. Any comment will be appreciated.
Regards,
Only in wget-1.5.3.new: Makefile
Only in wget-1.5.3.new: config.cache
Only in wget-1.5.3.new: config.log
Only in wget-1.5.3.new: config.status
Only in wget-1.5.3.new/doc: Makefile
diff -cr wget-1.5.3/doc/wget.texi wget-1.5.3.new/doc/wget.texi
*** wget-1.5.3/doc/wget.texi Fri Sep 11 09:34:56 1998
--- wget-1.5.3.new/doc/wget.texi Sun Mar 4 01:03:22 2001
***************
*** 722,727 ****
--- 722,739 ----
authentication on a proxy server. Wget will encode them using the
@code{basic} authentication scheme.
+ @cindex referer
+ @item --referer=@var{referer-string}
+ Use @var{referer-string} as a @code{Referer}. Wget usually sets
+ @code{Referer} automatically, but there're some cases where
+ @code{Referer} information is not available (e.g. when you retrieve
+ a file directly). In such a case, this option can be used to explicitly
+ specify @code{Referer}.
+
+ Note that this option doesn't override the one wget sets
+ automatically. Instead, this option has an effect only when wget doesn't
+ know the @code{Referer} information.
+
@cindex server response, save
@item -s
@itemx --save-headers
Only in wget-1.5.3.new/po: Makefile
Only in wget-1.5.3.new/po: Makefile.in
Only in wget-1.5.3.new/po: POTFILES
Binary files wget-1.5.3/po/cs.gmo and wget-1.5.3.new/po/cs.gmo differ
Binary files wget-1.5.3/po/de.gmo and wget-1.5.3.new/po/de.gmo differ
Binary files wget-1.5.3/po/hr.gmo and wget-1.5.3.new/po/hr.gmo differ
Binary files wget-1.5.3/po/it.gmo and wget-1.5.3.new/po/it.gmo differ
Binary files wget-1.5.3/po/no.gmo and wget-1.5.3.new/po/no.gmo differ
Binary files wget-1.5.3/po/pt_BR.gmo and wget-1.5.3.new/po/pt_BR.gmo differ
Only in wget-1.5.3.new/src: Makefile
Only in wget-1.5.3.new/src: config.h
diff -cr wget-1.5.3/src/init.c wget-1.5.3.new/src/init.c
*** wget-1.5.3/src/init.c Fri Sep 11 09:20:23 1998
--- wget-1.5.3.new/src/init.c Sat Mar 3 22:48:06 2001
***************
*** 133,138 ****
--- 133,139 ----
{ "quota", &opt.quota, cmd_bytes },
{ "reclevel", &opt.reclevel, cmd_number_inf },
{ "recursive", NULL, cmd_spec_recursive },
+ { "referer", &opt.referer, cmd_string },
{ "reject", &opt.rejects, cmd_vector },
{ "relativeonly", &opt.relative_only, cmd_boolean },
{ "removelisting", &opt.remove_listing, cmd_boolean },
***************
*** 922,927 ****
--- 923,929 ----
FREE_MAYBE (opt.http_proxy);
free_vec (opt.no_proxy);
FREE_MAYBE (opt.useragent);
+ FREE_MAYBE (opt.referer);
FREE_MAYBE (opt.http_user);
FREE_MAYBE (opt.http_passwd);
FREE_MAYBE (opt.user_header);
diff -cr wget-1.5.3/src/main.c wget-1.5.3.new/src/main.c
*** wget-1.5.3/src/main.c Fri Sep 11 10:41:53 1998
--- wget-1.5.3.new/src/main.c Sun Mar 4 00:00:59 2001
***************
*** 160,165 ****
--- 160,166 ----
--header=STRING insert STRING among the headers.\n\
--proxy-user=USER set USER as proxy username.\n\
--proxy-passwd=PASS set PASS as proxy password.\n\
+ --referer=STRING use STRING as a Referer:.\n\
-s, --save-headers save the HTTP headers to file.\n\
-U, --user-agent=AGENT identify as AGENT instead of Wget/VERSION.\n\
\n"), _("\
***************
*** 259,264 ****
--- 260,266 ----
{ "proxy-passwd", required_argument, NULL, 16 },
{ "proxy-user", required_argument, NULL, 15 },
{ "quota", required_argument, NULL, 'Q' },
+ { "referer", required_argument, NULL, 24 },
{ "reject", required_argument, NULL, 'R' },
{ "timeout", required_argument, NULL, 'T' },
{ "tries", required_argument, NULL, 't' },
***************
*** 435,440 ****
--- 437,445 ----
break;
case 23:
setval ("backups", optarg);
+ break;
+ case 24:
+ setval ("referer", optarg);
break;
case 'A':
setval ("accept", optarg);
diff -cr wget-1.5.3/src/options.h wget-1.5.3.new/src/options.h
*** wget-1.5.3/src/options.h Wed Apr 29 06:29:40 1998
--- wget-1.5.3.new/src/options.h Sat Mar 3 12:38:57 2001
***************
*** 118,123 ****
--- 118,127 ----
char *useragent; /* Naughty User-Agent, which can be
set to something other than
Wget. */
+
+ char *referer; /* if no referer info available,
+ this will be used */
+
int convert_links; /* Will the links be converted
locally? */
int remove_listing; /* Do we remove .listing files
diff -cr wget-1.5.3/src/retr.c wget-1.5.3.new/src/retr.c
*** wget-1.5.3/src/retr.c Sun May 17 10:08:38 1998
--- wget-1.5.3.new/src/retr.c Sat Mar 3 12:14:04 2001
***************
*** 322,328 ****
/* Set the referer. */
if (refurl)
u->referer = xstrdup (refurl);
! else
u->referer = NULL;
local_use_proxy = USE_PROXY_P (u);
--- 322,330 ----
/* Set the referer. */
if (refurl)
u->referer = xstrdup (refurl);
! else if (opt.referer)
! u->referer = xstrdup (opt.referer);
! else
u->referer = NULL;
local_use_proxy = USE_PROXY_P (u);
Only in wget-1.5.3.new: stamp-h
Only in wget-1.5.3.new/util: Makefile