Skip to content

Commit

Permalink
Simplify HTTPStatus by removing HTTPStatusCode
Browse files Browse the repository at this point in the history
  • Loading branch information
yvbeek committed Nov 9, 2018
1 parent 6390082 commit 26d5dd8
Show file tree
Hide file tree
Showing 3 changed files with 268 additions and 124 deletions.
5 changes: 5 additions & 0 deletions Sources/Helpers/Deprecations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ public extension HTTPStatus {
static let noResponse = HTTPStatus(code: 444, phrase: "No Response")
}

// MARK: - HTTPStatusCode

@available(*, deprecated, message: "use HTTPStatus, for example .ok or .notFound")
public typealias HTTPStatusCode = HTTPStatus

// MARK: - HTTPReponse

public extension HTTPResponse {
Expand Down
4 changes: 1 addition & 3 deletions Sources/Protocols/HTTP/Models/HTTPParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,8 @@ extension HTTPParser {
// Not done parsing the status? Continue
guard rawParser.isStatusComplete else { return continueParsing }

// Check that the status is valid
// Validate and set the status
guard let phrase = String(data: statusData, encoding: .utf8) else { return stopParsing }

// Set the status
response?.status = HTTPStatus(code: rawParser.httpStatusCode, phrase: phrase)

return continueParsing
Expand Down
Loading

0 comments on commit 26d5dd8

Please sign in to comment.