pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/net/libfetch
Module Name: pkgsrc
Committed By: jperkin
Date: Fri Oct 21 11:51:18 UTC 2016
Modified Files:
pkgsrc/net/libfetch: Makefile
pkgsrc/net/libfetch/files: http.c
Log Message:
libfetch-2.38: Support proxies for https URLs. From FreeBSD.
To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 pkgsrc/net/libfetch/Makefile
cvs rdiff -u -r1.39 -r1.40 pkgsrc/net/libfetch/files/http.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/net/libfetch/Makefile
diff -u pkgsrc/net/libfetch/Makefile:1.57 pkgsrc/net/libfetch/Makefile:1.58
--- pkgsrc/net/libfetch/Makefile:1.57 Thu Oct 20 21:25:57 2016
+++ pkgsrc/net/libfetch/Makefile Fri Oct 21 11:51:18 2016
@@ -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
Index: pkgsrc/net/libfetch/files/http.c
diff -u pkgsrc/net/libfetch/files/http.c:1.39 pkgsrc/net/libfetch/files/http.c:1.40
--- pkgsrc/net/libfetch/files/http.c:1.39 Thu Oct 20 21:21:25 2016
+++ pkgsrc/net/libfetch/files/http.c Fri Oct 21 11:51:18 2016
@@ -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 @@ http_authorize(conn_t *conn, const char
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 @@ 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_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 @@ http_connect(struct url *URL, struct url
errno = EPERM;
#endif
fetch_syserr();
- return (NULL);
+ goto ouch;
}
#if defined(TCP_NOPUSH) && !defined(__APPLE__)
@@ -770,6 +794,9 @@ http_connect(struct url *URL, struct url
#endif
return (conn);
+ouch:
+ fetch_close(conn);
+ return (NULL);
}
static struct url *
@@ -901,7 +928,7 @@ http_request(struct url *URL, const char
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