summaryrefslogtreecommitdiffstats
path: root/lib/libfetch/http.c
diff options
context:
space:
mode:
authoreadler <eadler@FreeBSD.org>2012-10-22 03:00:10 +0000
committereadler <eadler@FreeBSD.org>2012-10-22 03:00:10 +0000
commitf647c87f9c373d56d14471b8600d0151acf7ebb0 (patch)
tree5d18e5eb8a70ff62d5997b32b56717e2073ae80d /lib/libfetch/http.c
parente82cfe8e3006fa9ec6e0f1cf5bfc82b3668f5dda (diff)
downloadFreeBSD-src-f647c87f9c373d56d14471b8600d0151acf7ebb0.zip
FreeBSD-src-f647c87f9c373d56d14471b8600d0151acf7ebb0.tar.gz
Don't deny non-temporary redirects if the -A option is set (per
the man page) [0] While here add support for draft-reschke-http-status-308-07 PR: 172451 [0] Submitted by: gcooper [0] Reviewed by: des Approved by: cperciva MFC after: 1 week
Diffstat (limited to 'lib/libfetch/http.c')
-rw-r--r--lib/libfetch/http.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c
index d10e644..a1166bc 100644
--- a/lib/libfetch/http.c
+++ b/lib/libfetch/http.c
@@ -104,6 +104,7 @@ __FBSDID("$FreeBSD$");
#define HTTP_SEE_OTHER 303
#define HTTP_NOT_MODIFIED 304
#define HTTP_TEMP_REDIRECT 307
+#define HTTP_PERM_REDIRECT 308
#define HTTP_NEED_AUTH 401
#define HTTP_NEED_PROXY_AUTH 407
#define HTTP_BAD_RANGE 416
@@ -1524,8 +1525,7 @@ http_request(struct url *URL, const char *op, struct url_stat *us,
/* try the provided URL first */
url = URL;
- /* if the A flag is set, we only get one try */
- n = noredirect ? 1 : MAX_REDIRECT;
+ n = MAX_REDIRECT;
i = 0;
e = HTTP_PROTOCOL_ERROR;
@@ -1772,6 +1772,16 @@ http_request(struct url *URL, const char *op, struct url_stat *us,
case hdr_location:
if (!HTTP_REDIRECT(conn->err))
break;
+ /*
+ * if the A flag is set, we don't follow
+ * temporary redirects.
+ */
+ if (noredirect &&
+ conn->err != HTTP_MOVED_PERM &&
+ conn->err != HTTP_PERM_REDIRECT) {
+ n = 1;
+ break;
+ }
if (new)
free(new);
if (verbose)
OpenPOWER on IntegriCloud