From owner-svn-src-all@FreeBSD.ORG Sun May 26 17:00:16 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 29AE58B7; Sun, 26 May 2013 17:00:16 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 0BFA2294; Sun, 26 May 2013 17:00:16 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4QH0Fmh097147; Sun, 26 May 2013 17:00:15 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4QH0F99097145; Sun, 26 May 2013 17:00:15 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201305261700.r4QH0F99097145@svn.freebsd.org> From: Dag-Erling Smørgrav Date: Sun, 26 May 2013 17:00:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r251002 - stable/8/lib/libfetch X-SVN-Group: stable-8 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: Sun, 26 May 2013 17:00:16 -0000 Author: des Date: Sun May 26 17:00:15 2013 New Revision: 251002 URL: http://svnweb.freebsd.org/changeset/base/251002 Log: MFH (r230478): fix a couple of nits in r230307 (r231248) MFH (r243149): fix indentation MFH (r249431): use CONNECT to proxy HTTPS over HTTP PR: bin/80176 Modified: stable/8/lib/libfetch/common.c stable/8/lib/libfetch/http.c Directory Properties: stable/8/lib/libfetch/ (props changed) Modified: stable/8/lib/libfetch/common.c ============================================================================== --- stable/8/lib/libfetch/common.c Sun May 26 16:48:51 2013 (r251001) +++ stable/8/lib/libfetch/common.c Sun May 26 17:00:15 2013 (r251002) @@ -418,7 +418,6 @@ fetch_cache_data(conn_t *conn, char *src if (conn->cache.size < nbytes) { tmp = realloc(conn->cache.buf, nbytes); if (tmp == NULL) { - errno = ENOMEM; fetch_syserr(); return (-1); } @@ -481,7 +480,7 @@ fetch_read(conn_t *conn, char *buf, size conn->cache.len -= total; conn->cache.pos += total; len -= total; - buf+= total; + buf += total; } while (len > 0) { Modified: stable/8/lib/libfetch/http.c ============================================================================== --- stable/8/lib/libfetch/http.c Sun May 26 16:48:51 2013 (r251001) +++ stable/8/lib/libfetch/http.c Sun May 26 17:00:15 2013 (r251002) @@ -1373,6 +1373,7 @@ http_authorize(conn_t *conn, const char static conn_t * http_connect(struct url *URL, struct url *purl, const char *flags) { + struct url *curl; conn_t *conn; int verbose; int af, val; @@ -1391,17 +1392,21 @@ http_connect(struct url *URL, struct url af = AF_INET6; #endif - if (purl && strcasecmp(URL->scheme, SCHEME_HTTPS) != 0) { - URL = purl; - } else if (strcasecmp(URL->scheme, SCHEME_FTP) == 0) { - /* can't talk http to an ftp server */ - /* XXX should set an error code */ - return (NULL); - } + curl = (purl != NULL) ? purl : URL; - if ((conn = fetch_connect(URL->host, URL->port, af, verbose)) == NULL) + if ((conn = fetch_connect(curl->host, curl->port, af, verbose)) == NULL) /* fetch_connect() has already set an error code */ return (NULL); + if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0 && purl) { + http_cmd(conn, "CONNECT %s:%d HTTP/1.1", + URL->host, URL->port); + http_cmd(conn, ""); + if (http_get_reply(conn) != HTTP_OK) { + fetch_close(conn); + return (NULL); + } + http_get_reply(conn); + } if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0 && fetch_ssl(conn, verbose) == -1) { fetch_close(conn); @@ -1752,11 +1757,11 @@ http_request(struct url *URL, const char /* get headers. http_next_header expects one line readahead */ if (fetch_getln(conn) == -1) { - fetch_syserr(); - goto ouch; + fetch_syserr(); + goto ouch; } do { - switch ((h = http_next_header(conn, &headerbuf, &p))) { + switch ((h = http_next_header(conn, &headerbuf, &p))) { case hdr_syserror: fetch_syserr(); goto ouch; @@ -1785,7 +1790,7 @@ http_request(struct url *URL, const char conn->err != HTTP_USE_PROXY) { n = 1; break; - } + } if (new) free(new); if (verbose)