Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "302 Found" HTTP response #507

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Xcode/Sources/HttpResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public enum HttpResponse {
case switchProtocols([String: String], (Socket) -> Void)
case ok(HttpResponseBody, [String: String] = [:]), created, accepted
case movedPermanently(String)
case found(String)
case movedTemporarily(String)
case badRequest(HttpResponseBody?), unauthorized(HttpResponseBody?), forbidden(HttpResponseBody?), notFound(HttpResponseBody? = nil), notAcceptable(HttpResponseBody?), tooManyRequests(HttpResponseBody?), internalServerError(HttpResponseBody?)
case raw(Int, String, [String: String]?, ((HttpResponseBodyWriter) throws -> Void)? )
Expand All @@ -93,6 +94,7 @@ public enum HttpResponse {
case .created : return 201
case .accepted : return 202
case .movedPermanently : return 301
case .found : return 302
case .movedTemporarily : return 307
case .badRequest : return 400
case .unauthorized : return 401
Expand All @@ -112,6 +114,7 @@ public enum HttpResponse {
case .created : return "Created"
case .accepted : return "Accepted"
case .movedPermanently : return "Moved Permanently"
case .found : return "Found"
case .movedTemporarily : return "Moved Temporarily"
case .badRequest : return "Bad Request"
case .unauthorized : return "Unauthorized"
Expand Down Expand Up @@ -144,6 +147,8 @@ public enum HttpResponse {
}
case .movedPermanently(let location):
headers["Location"] = location
case .found(let location):
headers["Location"] = location
case .movedTemporarily(let location):
headers["Location"] = location
case .raw(_, _, let rawHeaders, _):
Expand Down