提交 eb7610c2 编写于 作者: G Giulio 提交者: Jon Shier

Improve cURLRepresentation implementation readability (#2625)

* Improve cURLRepresentation variable readability

* Further condense header handling.
上级 91538000
......@@ -320,21 +320,16 @@ extension Request: CustomDebugStringConvertible {
var headers: [AnyHashable: Any] = [:]
if let additionalHeaders = session.configuration.httpAdditionalHeaders {
for (field, value) in additionalHeaders where field != AnyHashable("Cookie") {
headers[field] = value
}
}
session.configuration.httpAdditionalHeaders?.filter { $0.0 != AnyHashable("Cookie") }
.forEach { headers[$0.0] = $0.1 }
if let headerFields = request.allHTTPHeaderFields {
for (field, value) in headerFields where field != "Cookie" {
headers[field] = value
}
}
request.allHTTPHeaderFields?.filter { $0.0 != "Cookie" }
.forEach { headers[$0.0] = $0.1 }
for (field, value) in headers {
let escapedValue = String(describing: value).replacingOccurrences(of: "\"", with: "\\\"")
components.append("-H \"\(field): \(escapedValue)\"")
components += headers.map {
let escapedValue = String(describing: $0.value).replacingOccurrences(of: "\"", with: "\\\"")
return "-H \"\($0.key): \(escapedValue)\""
}
if let httpBodyData = request.httpBody, let httpBody = String(data: httpBodyData, encoding: .utf8) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册