From 2dba640718dcac1d8fbf6550e953fc016f39a602 Mon Sep 17 00:00:00 2001 From: Kyle Jessup Date: Wed, 5 Oct 2016 18:36:45 -0400 Subject: [PATCH] added setsockopt on http connection --- .gitignore | 1 + Sources/PerfectHTTPServer/HTTPServer.swift | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/.gitignore b/.gitignore index 8a6a634..0b8e2d2 100644 --- a/.gitignore +++ b/.gitignore @@ -66,3 +66,4 @@ fastlane/test_output Packages/ *.xcodeproj/ +.DS_Store diff --git a/Sources/PerfectHTTPServer/HTTPServer.swift b/Sources/PerfectHTTPServer/HTTPServer.swift index b16b43e..6243234 100644 --- a/Sources/PerfectHTTPServer/HTTPServer.swift +++ b/Sources/PerfectHTTPServer/HTTPServer.swift @@ -22,6 +22,13 @@ import PerfectThread import PerfectLib import PerfectHTTP +#if os(Linux) + import SwiftGlibc + import LinuxBridge +#else + import Darwin +#endif + /// Stand-alone HTTP server. Provides the same WebConnection based interface as the FastCGI server. public class HTTPServer { @@ -214,6 +221,10 @@ public class HTTPServer { } func handleConnection(_ net: NetTCP) { + + var flag = 1 + _ = setsockopt(net.fd.fd, IPPROTO_TCP, TCP_NODELAY, &flag, UInt32(MemoryLayout.size)) + let req = HTTP11Request(connection: net) req.serverName = self.serverName req.readRequest { [weak self]