mirror of
https://github.com/apple/swift-nio
synced 2026-11-30 05:28:44 +00:00
better descriptions for HTTP{Response,Request}Head and HTTPVersion (#339)
Motivation:
We recently changed the backing for the HTTP request and response
objects so that the URI string was no longer visible in
`request.description`. This patch fixes that and prints a format like
this:
HTTPRequestHead { method: GET, uri: "/", version: HTTP/1.1, headers: [("Host", "localhost:8888"), ("User-Agent", "curl/7.54.0"), ("Accept", "*/*")] }
and
HTTPResponseHead { version: HTTP/1.1, status: ok, headers: [("content-length", "12")] }
Modifications:
improved the HTTP request/response descriptions
Result:
debugging is easier
This commit is contained in:
1 parent
91ef938c60
commit
56b540bfda
1 file changed
+18
@@ -1372,3 +1372,21 @@ extension HTTPResponseStatus: Equatable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension HTTPRequestHead: CustomStringConvertible {
|
||||
public var description: String {
|
||||
return "HTTPRequestHead { method: \(self.method), uri: \"\(self.uri)\", version: \(self.version), headers: \(self.headers) }"
|
||||
}
|
||||
}
|
||||
|
||||
extension HTTPResponseHead: CustomStringConvertible {
|
||||
public var description: String {
|
||||
return "HTTPResponseHead { version: \(self.version), status: \(self.status), headers: \(self.headers) }"
|
||||
}
|
||||
}
|
||||
|
||||
extension HTTPVersion: CustomStringConvertible {
|
||||
public var description: String {
|
||||
return "HTTP/\(self.major).\(self.minor)"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user