From owner-freebsd-bugs Fri Jun 15 1:30:30 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 085C937B408 for ; Fri, 15 Jun 2001 01:30:05 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.3/8.11.3) id f5F8U5n26367; Fri, 15 Jun 2001 01:30:05 -0700 (PDT) (envelope-from gnats) Received: from david.siemens.de (david.siemens.de [192.35.17.14]) by hub.freebsd.org (Postfix) with ESMTP id C202737B408 for ; Fri, 15 Jun 2001 01:26:27 -0700 (PDT) (envelope-from andre.albsmeier@mchp.siemens.de) Received: from mail2.siemens.de (mail2.siemens.de [139.25.208.11]) by david.siemens.de (8.11.0/8.11.0) with ESMTP id f5F8QN505933 for ; Fri, 15 Jun 2001 10:26:26 +0200 (MET DST) Received: from curry.mchp.siemens.de (curry.mchp.siemens.de [139.25.42.7]) by mail2.siemens.de (8.11.0/8.11.0) with ESMTP id f5F8QMh24331 for ; Fri, 15 Jun 2001 10:26:22 +0200 (MET DST) Received: (from localhost) by curry.mchp.siemens.de (8.11.3/8.11.3) id f5F8QMu68162 for FreeBSD-gnats-submit@freebsd.org; Fri, 15 Jun 2001 10:26:22 +0200 (CEST) Message-Id: <200106150826.f5F8QMA50898@curry.mchp.siemens.de> Date: Fri, 15 Jun 2001 10:26:22 +0200 (CEST) From: Andre Albsmeier To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: bin/28171: [PATCH] to support a HTTP_REFERER env variable in libfetch Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >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