From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= Subject: Re: url-fetch with referer Date: Fri, 31 May 2019 23:39:34 +0200 Message-ID: <878summhgp.fsf@gnu.org> References: <877eahyrb2.fsf@ambrevar.xyz> <875zpuy5x1.fsf@gnu.org> <87lfypwd1a.fsf@ambrevar.xyz> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([209.51.188.92]:35910) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWpFR-0004Us-Hb for guix-devel@gnu.org; Fri, 31 May 2019 17:39:38 -0400 In-Reply-To: <87lfypwd1a.fsf@ambrevar.xyz> (Pierre Neidhardt's message of "Wed, 29 May 2019 16:28:17 +0200") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Pierre Neidhardt Cc: Guix-devel Pierre Neidhardt skribis: > Ludovic Court=C3=A8s writes: > >> More generally, we=E2=80=99ve added a couple of HTTP headers for issues = that >> were relatively common. We could easily fix this one, but maybe you >> could first talk to the webmasters, because requiring =E2=80=98Referer= =E2=80=99 sounds >> obnoxious; WDYT? > > So I did for 1 website and the answer was that this is on purpose, to > "avoid linking directly to the archive from a different website." A > rather delusional enforcement, but hey, if we can't convince the webmaste= rs... > > How would we add the relevant HTTP header then? See =E2=80=98http-fetch=E2=80=99 in (guix build download). (It would be more convincing if this is for a package to be included in Guix proper, hint hint. :-)) >> (Note that in the meantime you can always work around the problem by >> writing your own fixed-output derivation.) > > I don't understand, can you explain? You could write something like: --8<---------------cut here---------------start------------->8--- (define* (my-url-fetch url hash-algo hash #:optional name #:key (system (%current-system)) (guile (default-guile))) (define file-name (match url ((head _ ...) (basename head)) (_ (basename url)))) (let ((uri (and (string? url) (string->uri url)))) (gexp->derivation name #~(begin (use-modules (web client)) (http-get =E2=80=A6 #:headers =E2=80=A6) =E2=80=A6) ;; =E2=80=A6 #:hash hash #:hash-algo hash-algo))) --8<---------------cut here---------------end--------------->8--- HTH! Ludo=E2=80=99.