Date: Mon, 29 Oct 2012 04:16:53 +0000 (UTC) From: Eitan Adler <eadler@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Subject: svn commit: r242290 - stable/7/lib/libfetch Message-ID: <201210290416.q9T4GrPx074297@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: eadler Date: Mon Oct 29 04:16:52 2012 New Revision: 242290 URL: http://svn.freebsd.org/changeset/base/242290 Log: MFC r241840: 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] Approved by: cperciva (implicit) Modified: stable/7/lib/libfetch/http.c stable/7/lib/libfetch/http.errors Directory Properties: stable/7/lib/libfetch/ (props changed) Modified: stable/7/lib/libfetch/http.c ============================================================================== --- stable/7/lib/libfetch/http.c Mon Oct 29 04:16:52 2012 (r242289) +++ stable/7/lib/libfetch/http.c Mon Oct 29 04:16:52 2012 (r242290) @@ -96,6 +96,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 @@ -1509,8 +1510,7 @@ http_request(struct url *URL, const char /* 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; @@ -1757,6 +1757,16 @@ http_request(struct url *URL, const char 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) Modified: stable/7/lib/libfetch/http.errors ============================================================================== --- stable/7/lib/libfetch/http.errors Mon Oct 29 04:16:52 2012 (r242289) +++ stable/7/lib/libfetch/http.errors Mon Oct 29 04:16:52 2012 (r242290) @@ -18,6 +18,7 @@ 304 OK Not Modified 305 INFO Use Proxy 307 MOVED Temporary Redirect +308 MOVED Permanent Redirect 400 PROTO Bad Request 401 AUTH Unauthorized 402 AUTH Payment Required
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210290416.q9T4GrPx074297>