Date: Fri, 15 Jun 2001 10:26:22 +0200 (CEST) From: Andre Albsmeier <andre.albsmeier@mchp.siemens.de> To: FreeBSD-gnats-submit@freebsd.org Subject: bin/28171: [PATCH] to support a HTTP_REFERER env variable in libfetch Message-ID: <200106150826.f5F8QMA50898@curry.mchp.siemens.de>
next in thread | raw e-mail | index | archive | help
>Number: 28171 >Category: bin >Synopsis: [PATCH] to support a HTTP_REFERER env variable in libfetch >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Jun 15 01:30:04 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Andre Albsmeier >Release: FreeBSD 4.3-STABLE i386 >Organization: >Environment: All FreeBSD systems >Description: Some webservers insist on a Referer: header in http requests. >How-To-Repeat: >Fix: The patch is similar as for HTTP_USER_AGENT. Additionally, if HTTP_REFERER=auto is used, an appropriate referer is constructed from the URL (this is OK in 95% of all cases). --- lib/libfetch/http.c.ORI Fri Jun 15 09:21:40 2001 +++ lib/libfetch/http.c Fri Jun 15 10:14:38 2001 @@ -775,6 +775,15 @@ } /* other headers */ + if ((p = getenv("HTTP_REFERER")) != NULL && *p != '\0') { + if (strcmp(p,"auto") == 0) { + char ps[7]; + snprintf (ps,sizeof(ps),":%d",url->port); + _http_cmd(fd, "Referer: %s://%s%s%s", + url->scheme, host, url->port == 80 ? "" : ps, url->doc); + } else + _http_cmd(fd,"Referer: %s",p); + } if ((p = getenv("HTTP_USER_AGENT")) != NULL && *p != '\0') _http_cmd(fd, "User-Agent: %s", p); else --- lib/libfetch/fetch.3.ORI Fri Jun 15 09:46:18 2001 +++ lib/libfetch/fetch.3 Fri Jun 15 10:16:14 2001 @@ -491,6 +491,10 @@ Specifies the User-Agent string to use for HTTP requests. This can be useful when working with HTTP origin or proxy servers that differentiate between usder agents. +.It Ev HTTP_REFERER +Specifies the Referer string to use for HTTP requests. +This can be useful when working with HTTP servers that insist in them. +When set to "auto" the URL is taken to construct a referer value. .El .Sh SEE ALSO .Xr fetch 1 , >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200106150826.f5F8QMA50898>