swifter icon indicating copy to clipboard operation
swifter copied to clipboard

Socket is closed using .raw response even with keep-alive header

Open Matthieu614 opened this issue 4 years ago • 0 comments

Hi,

I have an issue using .raw response with keep alive header: the socket is closed cause .raw content length cannot be anything but -1 (even if i actually write content using HttpResponseBodyWriter)

HTTPServerIO.swift:l.202

private func respond(_ socket: Socket, response: HttpResponse, keepAlive: Bool) throws -> Bool {
        guard self.operating else { return false }
 
       [...]

        if keepAlive && content.length != -1 {
            responseHeader.append("Connection: keep-alive\r\n")
        }

       [...]

        return keepAlive && content.length != -1

I really need the socket to respect the keep-alive for IoT devices usage purposes

Thanks, have a great day,

Matthieu

Matthieu614 avatar Aug 30 '21 08:08 Matthieu614