no auto headers for GET

This commit is contained in:
Johannes Weiss committed 2018-01-19 15:46:52 +00:00
1 parent 24abe7fe19
commit 7d5109a673
4 files changed
+40 -10

No files matched your search

+14 -5
View File
@@ -358,6 +358,12 @@ extension HTTPHeaders : Equatable {
}
public enum HTTPMethod: Equatable {
public enum HasBody {
case yes
case no
case unlikely
}
public static func ==(lhs: HTTPMethod, rhs: HTTPMethod) -> Bool {
switch (lhs, rhs){
case (.GET, .GET):
@@ -469,13 +475,16 @@ public enum HTTPMethod: Equatable {
case RAW(value: String)
/// Whether requests with this verb may have a request body.
public var mayHaveRequestBody: Bool {
// TODO: Add more
public var hasRequestBody: HasBody {
switch self {
case .HEAD:
return false
case .HEAD, .DELETE, .TRACE:
return .no
case .POST, .PUT, .CONNECT, .PATCH:
return .yes
case .GET, .OPTIONS:
fallthrough
default:
return true
return .unlikely
}
}
}