mirror of
https://github.com/apple/swift-nio
synced 2026-11-30 05:28:44 +00:00
no auto headers for GET
This commit is contained in:
1 parent
24abe7fe19
commit
7d5109a673
4 files changed
+40
-10
No files matched your search
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user