summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2013-07-30 13:07:55 +0000
committerdes <des@FreeBSD.org>2013-07-30 13:07:55 +0000
commit0b1a1b2338ac2d3a4cf2143e0dc12165224165f0 (patch)
treec1861e9adce3415d9dfbd32bebf77ef0dbdc08eb /lib
parentb0032aebc5c7586f5d4744ba55479016ab141d73 (diff)
downloadFreeBSD-src-0b1a1b2338ac2d3a4cf2143e0dc12165224165f0.zip
FreeBSD-src-0b1a1b2338ac2d3a4cf2143e0dc12165224165f0.tar.gz
Include an Accept header in requests.
PR: kern/180917 MFC after: 1 week
Diffstat (limited to 'lib')
-rw-r--r--lib/libfetch/fetch.313
-rw-r--r--lib/libfetch/http.c8
2 files changed, 18 insertions, 3 deletions
diff --git a/lib/libfetch/fetch.3 b/lib/libfetch/fetch.3
index 34ca445..6b2e4c0 100644
--- a/lib/libfetch/fetch.3
+++ b/lib/libfetch/fetch.3
@@ -1,5 +1,5 @@
.\"-
-.\" Copyright (c) 1998-2011 Dag-Erling Smørgrav
+.\" Copyright (c) 1998-2013 Dag-Erling Smørgrav
.\" Copyright (c) 2013 Michael Gmelin <freebsd@grem.de>
.\" All rights reserved.
.\"
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd January 25, 2013
+.Dd July 30, 2013
.Dt FETCH 3
.Os
.Sh NAME
@@ -571,6 +571,15 @@ variable is set.
Same as
.Ev FTP_PROXY ,
for compatibility.
+.It Ev HTTP_ACCEPT
+Specifies the value of the
+.Va Accept
+header for HTTP requests.
+If empty, no
+.Va Accept
+header is sent.
+The default is
+.Dq */* .
.It Ev HTTP_AUTH
Specifies HTTP authorization parameters as a colon-separated list of
items.
diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c
index 1fbc5ff..99b8030 100644
--- a/lib/libfetch/http.c
+++ b/lib/libfetch/http.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2000-2011 Dag-Erling Smørgrav
+ * Copyright (c) 2000-2013 Dag-Erling Smørgrav
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -1664,6 +1664,12 @@ http_request(struct url *URL, const char *op, struct url_stat *us,
}
/* other headers */
+ if ((p = getenv("HTTP_ACCEPT")) != NULL) {
+ if (*p != '\0')
+ http_cmd(conn, "Accept: %s", p);
+ } else {
+ http_cmd(conn, "Accept: */*");
+ }
if ((p = getenv("HTTP_REFERER")) != NULL && *p != '\0') {
if (strcasecmp(p, "auto") == 0)
http_cmd(conn, "Referer: %s://%s%s",
OpenPOWER on IntegriCloud