|
@@ -82,6 +82,7 @@ public enum HttpResponse {
|
|
|
case switchProtocols([String: String], (Socket) -> Void)
|
|
case switchProtocols([String: String], (Socket) -> Void)
|
|
|
case ok(HttpResponseBody), created, accepted
|
|
case ok(HttpResponseBody), created, accepted
|
|
|
case movedPermanently(String)
|
|
case movedPermanently(String)
|
|
|
|
|
+ case movedTemporarily(String)
|
|
|
case badRequest(HttpResponseBody?), unauthorized, forbidden, notFound
|
|
case badRequest(HttpResponseBody?), unauthorized, forbidden, notFound
|
|
|
case internalServerError
|
|
case internalServerError
|
|
|
case raw(Int, String, [String:String]?, ((HttpResponseBodyWriter) throws -> Void)? )
|
|
case raw(Int, String, [String:String]?, ((HttpResponseBodyWriter) throws -> Void)? )
|
|
@@ -93,6 +94,7 @@ public enum HttpResponse {
|
|
|
case .created : return 201
|
|
case .created : return 201
|
|
|
case .accepted : return 202
|
|
case .accepted : return 202
|
|
|
case .movedPermanently : return 301
|
|
case .movedPermanently : return 301
|
|
|
|
|
+ case .movedTemporarily : return 307
|
|
|
case .badRequest(_) : return 400
|
|
case .badRequest(_) : return 400
|
|
|
case .unauthorized : return 401
|
|
case .unauthorized : return 401
|
|
|
case .forbidden : return 403
|
|
case .forbidden : return 403
|
|
@@ -109,6 +111,7 @@ public enum HttpResponse {
|
|
|
case .created : return "Created"
|
|
case .created : return "Created"
|
|
|
case .accepted : return "Accepted"
|
|
case .accepted : return "Accepted"
|
|
|
case .movedPermanently : return "Moved Permanently"
|
|
case .movedPermanently : return "Moved Permanently"
|
|
|
|
|
+ case .movedTemporarily : return "Moved Temporarily"
|
|
|
case .badRequest(_) : return "Bad Request"
|
|
case .badRequest(_) : return "Bad Request"
|
|
|
case .unauthorized : return "Unauthorized"
|
|
case .unauthorized : return "Unauthorized"
|
|
|
case .forbidden : return "Forbidden"
|
|
case .forbidden : return "Forbidden"
|
|
@@ -133,6 +136,8 @@ public enum HttpResponse {
|
|
|
}
|
|
}
|
|
|
case .movedPermanently(let location):
|
|
case .movedPermanently(let location):
|
|
|
headers["Location"] = location
|
|
headers["Location"] = location
|
|
|
|
|
+ case .movedTemporarily(let location):
|
|
|
|
|
+ headers["Location"] = location
|
|
|
case .raw(_, _, let rawHeaders, _):
|
|
case .raw(_, _, let rawHeaders, _):
|
|
|
if let rawHeaders = rawHeaders {
|
|
if let rawHeaders = rawHeaders {
|
|
|
for (k, v) in rawHeaders {
|
|
for (k, v) in rawHeaders {
|