summaryrefslogtreecommitdiffstats
path: root/lib/libfetch/http.c
diff options
context:
space:
mode:
authorkbyanc <kbyanc@FreeBSD.org>2005-02-16 00:22:20 +0000
committerkbyanc <kbyanc@FreeBSD.org>2005-02-16 00:22:20 +0000
commitbdfff0682fa355a72509fc2be9f2ed2c735f96b0 (patch)
treea23dbc9325424c560d596a85a9cb3a827c638929 /lib/libfetch/http.c
parentc3757b437a1247a6cbc1f6c5d41312f1faa9eb4a (diff)
downloadFreeBSD-src-bdfff0682fa355a72509fc2be9f2ed2c735f96b0.zip
FreeBSD-src-bdfff0682fa355a72509fc2be9f2ed2c735f96b0.tar.gz
Set TCP_NOPUSH on HTTP requests, reducing the number of round-trips
necessary to establish each connection. MFC after: 2 weeks
Diffstat (limited to 'lib/libfetch/http.c')
-rw-r--r--lib/libfetch/http.c10
1 files changed, 9 insertions, 1 deletions
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 <time.h>
#include <unistd.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+
#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)) {
OpenPOWER on IntegriCloud