From bdfff0682fa355a72509fc2be9f2ed2c735f96b0 Mon Sep 17 00:00:00 2001 From: kbyanc Date: Wed, 16 Feb 2005 00:22:20 +0000 Subject: Set TCP_NOPUSH on HTTP requests, reducing the number of round-trips necessary to establish each connection. MFC after: 2 weeks --- lib/libfetch/http.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/libfetch/http.c') diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c index 3808507..d0008aa 100644 --- a/lib/libfetch/http.c +++ b/lib/libfetch/http.c @@ -76,6 +76,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include + #include "fetch.h" #include "common.h" #include "httperr.h" @@ -670,7 +673,7 @@ _http_connect(struct url *URL, struct url *purl, const char *flags) { conn_t *conn; int verbose; - int af; + int af, val; #ifdef INET6 af = AF_UNSPEC; @@ -705,6 +708,10 @@ _http_connect(struct url *URL, struct url *purl, const char *flags) _fetch_syserr(); return (NULL); } + + val = 1; + setsockopt(conn->sd, IPPROTO_TCP, TCP_NOPUSH, &val, sizeof(val)); + return (conn); } @@ -906,6 +913,7 @@ _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); /* get reply */ switch (_http_get_reply(conn)) { -- cgit v1.1