Skip to content

Commit f37bd60

Browse files
seabayleaparkera
authored andcommitted
Allow httpAdditionalHeaders to contain Strings or NSStrings (#625)
1 parent 68ce623 commit f37bd60

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Foundation/NSURLSession/Configuration.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,17 @@ private func convertToStringString(dictionary: [AnyHashable:Any]) -> [String: St
130130
// C.f. <https://github.com/apple/swift-corelibs-foundation/pull/287>
131131
var r: [String: String] = [:]
132132
dictionary.forEach {
133-
let k = String(describing: $0.key as! NSString)
134-
let v = String(describing: $0.value as! NSString)
133+
let k = getString(from: $0.key)
134+
let v = getString(from: $0.value)
135135
r[k] = v
136136
}
137137
return r
138138
}
139+
140+
private func getString(from obj: Any) -> String {
141+
if let string = obj as? String {
142+
return string
143+
} else {
144+
return String(describing: obj as! NSString)
145+
}
146+
}

0 commit comments

Comments
 (0)