Skip to content

Commit

Permalink
Add missing header
Browse files Browse the repository at this point in the history
  • Loading branch information
noppoMan committed Apr 18, 2016
1 parent 5f4cbb8 commit 3ac60ff
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions Sources/Slimane.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

public class Slimane {
internal var middlewares: [AsyncMiddleware] = []

internal var router: Router

public var setNodelay = false
Expand All @@ -30,7 +30,7 @@ public class Slimane {
result { Response() }
}
}

internal func dispatch(request: Request, stream: Skelton.HTTPStream){
var request = request
let responder: AsyncResponder
Expand All @@ -43,7 +43,11 @@ public class Slimane {
}
return
}
route.handler.respond(to: request, result: result)
route.handler.respond(to: request) { chainedResponse in
result {
request.response.merged(try chainedResponse())
}
}
}
} else {
responder = BasicAsyncResponder { [unowned self] _, result in
Expand All @@ -60,10 +64,17 @@ public class Slimane {
}
}
}

private func processStream(response: Response, _ request: Request, _ stream: Skelton.HTTPStream){
var response = response

response.headers["Date"] = Header(Time().rfc1123)
response.headers["Server"] = Header("Slimane")

if response.headers["Connection"].isEmpty {
response.headers["Connection"] = Header(request.isKeepAlive ? "Keep-Alive" : "Close")
}

if response.contentLength == 0 && !response.isChunkEncoded {
response.contentLength = response.bodyLength
}
Expand Down

0 comments on commit 3ac60ff

Please sign in to comment.