mirror of
https://github.com/swift-server/async-http-client.git
synced 2026-05-03 07:32:29 +00:00
Prepare async/await API for public release (#531)
This commit is contained in:
@@ -24,9 +24,9 @@ extension HTTPHeaders {
|
||||
|
||||
if case .TRACE = method {
|
||||
switch bodyLength {
|
||||
case .fixed(length: 0):
|
||||
case .known(0):
|
||||
break
|
||||
case .dynamic, .fixed:
|
||||
case .unknown, .known:
|
||||
// A client MUST NOT send a message body in a TRACE request.
|
||||
// https://tools.ietf.org/html/rfc7230#section-4.3.8
|
||||
throw HTTPClientError.traceRequestWithBody
|
||||
@@ -37,9 +37,9 @@ extension HTTPHeaders {
|
||||
|
||||
let connectionClose = self[canonicalForm: "connection"].lazy.map { $0.lowercased() }.contains("close")
|
||||
switch bodyLength {
|
||||
case .dynamic:
|
||||
case .unknown:
|
||||
return .init(connectionClose: connectionClose, body: .stream)
|
||||
case .fixed(let length):
|
||||
case .known(let length):
|
||||
return .init(connectionClose: connectionClose, body: .fixedSize(length))
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ extension HTTPHeaders {
|
||||
self.remove(name: "Transfer-Encoding")
|
||||
|
||||
switch bodyLength {
|
||||
case .fixed(0):
|
||||
case .known(0):
|
||||
// if we don't have a body we might not need to send the Content-Length field
|
||||
// https://tools.ietf.org/html/rfc7230#section-3.3.2
|
||||
switch method {
|
||||
@@ -103,9 +103,9 @@ extension HTTPHeaders {
|
||||
// for an enclosed payload body.
|
||||
self.add(name: "Content-Length", value: "0")
|
||||
}
|
||||
case .fixed(let length):
|
||||
case .known(let length):
|
||||
self.add(name: "Content-Length", value: String(length))
|
||||
case .dynamic:
|
||||
case .unknown:
|
||||
self.add(name: "Transfer-Encoding", value: "chunked")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user