[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: url-fetch with referer
From: |
Ludovic Courtès |
Subject: |
Re: url-fetch with referer |
Date: |
Fri, 31 May 2019 23:39:34 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) |
Pierre Neidhardt <address@hidden> skribis:
> Ludovic Courtès <address@hidden> writes:
>
>> More generally, we’ve 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 ‘Referer’ 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 webmasters...
>
> How would we add the relevant HTTP header then?
See ‘http-fetch’ 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 … #:headers …)
…)
;; …
#:hash hash
#:hash-algo hash-algo)))
--8<---------------cut here---------------end--------------->8---
HTH!
Ludo’.