summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2018-11-25 16:40:42 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2018-11-25 17:22:43 +0100
commit37de1902919ac27d4527edc4210f1f927ea376ef (patch)
tree9df5ae4fb7c7418f84ac3eeb2ab15c49b13acbb8
parent85399d2b28ba0bbd3b66e1ab50fde43a9f301f68 (diff)
Allow setting Referer header for http method
Not needed for common interactions, but for some download-file interactions it could be useful to set a specific referer as some servers do not serve requested files otherwise.
-rw-r--r--doc/examples/configure-index1
-rw-r--r--methods/http.cc4
2 files changed, 5 insertions, 0 deletions
diff --git a/doc/examples/configure-index b/doc/examples/configure-index
index 65590f17b..99aedfd19 100644
--- a/doc/examples/configure-index
+++ b/doc/examples/configure-index
@@ -270,6 +270,7 @@ Acquire
No-Store "false"; // Prevent the cache from storing archives
Dl-Limit "<INT>"; // Kb/sec maximum download rate
User-Agent "Debian APT-HTTP/1.3";
+ Referer "<STRING>"; // Set the HTTP Referer [sic!] header to given value
};
// HTTPS method configuration: uses the http
diff --git a/methods/http.cc b/methods/http.cc
index 2e7fca307..d75e9fe84 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -974,6 +974,10 @@ void HttpMethod::SendReq(FetchItem *Itm)
Req << "User-Agent: " << ConfigFind("User-Agent",
"Debian APT-HTTP/1.3 (" PACKAGE_VERSION ")") << "\r\n";
+ auto const referer = ConfigFind("Referer", "");
+ if (referer.empty() == false)
+ Req << "Referer: " << referer << "\r\n";
+
Req << "\r\n";
if (Debug == true)