Skip to content

Commit e877546

Browse files
mamabusiphausler
authored andcommitted
Implementation of NSObject's 'description' property (overriding) (#395)
for NSURLHttpResponse object
1 parent b166b15 commit e877546

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Foundation/NSURLResponse.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,21 @@ public class NSHTTPURLResponse : URLResponse {
228228
default: return "Server Error"
229229
}
230230
}
231+
232+
/// A string that represents the contents of the NSHTTPURLResponse Object.
233+
/// This property is intended to produce readable output.
234+
override public var description: String {
235+
var result = "<\(self.dynamicType) \(unsafeAddress(of: self))> { URL: \(url!.absoluteString) }{ status: \(statusCode), headers {\n"
236+
for(key, value) in allHeaderFields {
237+
if((key.lowercased() == "content-disposition" && suggestedFilename != "Unknown") || key.lowercased() == "content-type") {
238+
result += " \"\(key)\" = \"\(value)\";\n"
239+
} else {
240+
result += " \"\(key)\" = \(value);\n"
241+
}
242+
}
243+
result += "} }"
244+
return result
245+
}
231246
}
232247

233248
/// Parses the expected content length from the headers.

0 commit comments

Comments
 (0)