summaryrefslogtreecommitdiffstats
path: root/lib/libfetch/http.c
diff options
context:
space:
mode:
authorkbyanc <kbyanc@FreeBSD.org>2005-03-02 19:09:28 +0000
committerkbyanc <kbyanc@FreeBSD.org>2005-03-02 19:09:28 +0000
commit392eda7ce97b5762025db4b56b781cee5f597fc9 (patch)
tree507f0b109569c9125a6c0197319a591ed7f1e8f6 /lib/libfetch/http.c
parent0c521317a0dbf353cde1d0098681761b5d0e8b09 (diff)
downloadFreeBSD-src-392eda7ce97b5762025db4b56b781cee5f597fc9.zip
FreeBSD-src-392eda7ce97b5762025db4b56b781cee5f597fc9.tar.gz
Set the TCP_NODELAY socket option and clear TCP_NOPUSH in order to flush
any pending HTTP request rather than calling shutdown(2) with SHUT_WR. This makes libfetch (and thus fetch(1)) work again with Squid proxies configured to not allow half-closed connections. Reported by: Pawel Worach (pawel.worach AT telia DOT com)
Diffstat (limited to 'lib/libfetch/http.c')
-rw-r--r--lib/libfetch/http.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c
index d0008aa..bac7b0f 100644
--- a/lib/libfetch/http.c
+++ b/lib/libfetch/http.c
@@ -792,7 +792,7 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
conn_t *conn;
struct url *url, *new;
int chunked, direct, need_auth, noredirect, verbose;
- int e, i, n;
+ int e, i, n, val;
off_t offset, clength, length, size;
time_t mtime;
const char *p;
@@ -913,7 +913,20 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
_http_cmd(conn, "Range: bytes=%lld-", (long long)url->offset);
_http_cmd(conn, "Connection: close");
_http_cmd(conn, "");
- shutdown(conn->sd, SHUT_WR);
+
+ /*
+ * Force the queued request to be dispatched. Normally, one
+ * would do this with shutdown(2) but squid proxies can be
+ * configured to disallow such half-closed connections. To
+ * be compatible with such configurations, fiddle with socket
+ * options to force the pending data to be written.
+ */
+ val = 0;
+ setsockopt(conn->sd, IPPROTO_TCP, TCP_NOPUSH, &val,
+ sizeof(val));
+ val = 1;
+ setsockopt(conn->sd, IPPROTO_TCP, TCP_NODELAY, &val,
+ sizeof(val));
/* get reply */
switch (_http_get_reply(conn)) {
OpenPOWER on IntegriCloud