From owner-svn-src-all@FreeBSD.ORG Mon Oct 22 03:00:10 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C7206DE6; Mon, 22 Oct 2012 03:00:10 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 976AD8FC17; Mon, 22 Oct 2012 03:00:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q9M30AGx016144; Mon, 22 Oct 2012 03:00:10 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q9M30ArX016141; Mon, 22 Oct 2012 03:00:10 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201210220300.q9M30ArX016141@svn.freebsd.org> From: Eitan Adler Date: Mon, 22 Oct 2012 03:00:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r241840 - head/lib/libfetch X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Oct 2012 03:00:10 -0000 Author: eadler Date: Mon Oct 22 03:00:10 2012 New Revision: 241840 URL: http://svn.freebsd.org/changeset/base/241840 Log: 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 Modified: head/lib/libfetch/http.c head/lib/libfetch/http.errors Modified: head/lib/libfetch/http.c ============================================================================== --- head/lib/libfetch/http.c Mon Oct 22 03:00:04 2012 (r241839) +++ head/lib/libfetch/http.c Mon Oct 22 03:00:10 2012 (r241840) @@ -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 /* 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 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: head/lib/libfetch/http.errors ============================================================================== --- head/lib/libfetch/http.errors Mon Oct 22 03:00:04 2012 (r241839) +++ head/lib/libfetch/http.errors Mon Oct 22 03:00:10 2012 (r241840) @@ -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