pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/net/libfetch libfetch-2.38: Support proxies for https ...
details: https://anonhg.NetBSD.org/pkgsrc/rev/9108822ddf6b
branches: trunk
changeset: 354179:9108822ddf6b
user: jperkin <jperkin%pkgsrc.org@localhost>
date: Fri Oct 21 11:51:18 2016 +0000
description:
libfetch-2.38: Support proxies for https URLs. From FreeBSD.
diffstat:
net/libfetch/Makefile | 4 +-
net/libfetch/files/http.c | 51 +++++++++++++++++++++++++++++++++++-----------
2 files changed, 41 insertions(+), 14 deletions(-)
diffs (117 lines):
diff -r 7c5682f59552 -r 9108822ddf6b net/libfetch/Makefile
--- a/net/libfetch/Makefile Fri Oct 21 11:45:44 2016 +0000
+++ b/net/libfetch/Makefile Fri Oct 21 11:51:18 2016 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.57 2016/10/20 21:25:57 joerg Exp $
+# $NetBSD: Makefile,v 1.58 2016/10/21 11:51:18 jperkin Exp $
#
-DISTNAME= libfetch-2.37
+DISTNAME= libfetch-2.38
CATEGORIES= net
MASTER_SITES= # empty
DISTFILES= # empty
diff -r 7c5682f59552 -r 9108822ddf6b net/libfetch/files/http.c
--- a/net/libfetch/files/http.c Fri Oct 21 11:45:44 2016 +0000
+++ b/net/libfetch/files/http.c Fri Oct 21 11:51:18 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: http.c,v 1.39 2016/10/20 21:21:25 joerg Exp $ */
+/* $NetBSD: http.c,v 1.40 2016/10/21 11:51:18 jperkin Exp $ */
/*-
* Copyright (c) 2000-2004 Dag-Erling Coïdan Smørgrav
* Copyright (c) 2003 Thomas Klausner <wiz%NetBSD.org@localhost>
@@ -713,7 +713,10 @@
static conn_t *
http_connect(struct url *URL, struct url *purl, const char *flags, int *cached)
{
+ struct url *curl;
conn_t *conn;
+ hdr_t h;
+ const char *p;
int af, verbose;
#if defined(TCP_NOPUSH) && !defined(__APPLE__)
int val;
@@ -735,25 +738,46 @@
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_cache_get(URL, af)) != NULL) {
*cached = 1;
return (conn);
}
- if ((conn = fetch_connect(URL, af, verbose)) == NULL)
+ if ((conn = fetch_connect(curl, 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\r\n",
+ URL->host, URL->port);
+ http_cmd(conn, "Host: %s:%d\r\n",
+ URL->host, URL->port);
+ http_cmd(conn, "\r\n");
+ if (http_get_reply(conn) != HTTP_OK) {
+ http_seterr(conn->err);
+ goto ouch;
+ }
+ /* Read and discard the rest of the proxy response */
+ if (fetch_getln(conn) < 0) {
+ fetch_syserr();
+ goto ouch;
+ }
+ do {
+ switch ((h = http_next_header(conn, &p))) {
+ case hdr_syserror:
+ fetch_syserr();
+ goto ouch;
+ case hdr_error:
+ http_seterr(HTTP_PROTOCOL_ERROR);
+ goto ouch;
+ default:
+ /* ignore */ ;
+ }
+ } while (h < hdr_end);
+ }
if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0 &&
fetch_ssl(conn, URL, verbose) == -1) {
- fetch_close(conn);
/* grrr */
#ifdef EAUTH
errno = EAUTH;
@@ -761,7 +785,7 @@
errno = EPERM;
#endif
fetch_syserr();
- return (NULL);
+ goto ouch;
}
#if defined(TCP_NOPUSH) && !defined(__APPLE__)
@@ -770,6 +794,9 @@
#endif
return (conn);
+ouch:
+ fetch_close(conn);
+ return (NULL);
}
static struct url *
@@ -901,7 +928,7 @@
if (verbose)
fetch_info("requesting %s://%s%s",
url->scheme, host, url->doc);
- if (purl) {
+ if (purl && strcasecmp(URL->scheme, SCHEME_HTTPS) != 0) {
http_cmd(conn, "%s %s://%s%s HTTP/1.1\r\n",
op, url->scheme, host, url->doc);
} else {
Home |
Main Index |
Thread Index |
Old Index