 }
 
 func isBreadChallenge(_ r: HTTPURLResponse) -> Bool {
-    if let challenge = getHeaderValue("www-authenticate", d: r.allHeaderFields as Dictionary<NSObject, AnyObject>) {
+    if let headers = r.allHeaderFields as? [String: String],
+       let challenge = getHeaderValue("www-authenticate", d: headers) {
         if challenge.lowercased().hasPrefix("bread") {
             return true
         }

    return urlStr
}

func buildRequestSigningString(_ r: NSMutableURLRequest) -> String {
    let headers = r.allHTTPHeaderFields ?? Dictionary<String, String>()
    var parts = [
        r.httpMethod,
        "",
        getHeaderValue("content-type", d: headers as Dictionary<NSObject, AnyObject>) ?? "",
        getHeaderValue("date", d: headers as Dictionary<NSObject, AnyObject>) ?? "",
        buildURLResourceString(r.url)
    ]
    switch r.httpMethod {
    case "POST", "PUT", "PATCH":
        if let d = r.httpBody , d.count > 0 {
            let sha = (d as NSData).sha256()
            parts[1] = (NSData(uInt256: sha) as NSData).base58String()
        }
    default: break
    }
    return parts.joined(separator: "\n")
}

                    self.client.log("[KV] PUT key=\(key) err=\(err)")
                    return completionFunc(0, Date(timeIntervalSince1970: 0), [], .unknown)
                }
                guard let resp = resp, let v = self._extractVersion(resp),
                    let d = self._extractDate(resp), let dat = dat else {
                    return completionFunc(0, Date(timeIntervalSince1970: 0), [], .unknown)
                }
                let ud = (dat as NSData).bytes.bindMemory(to: UInt8.self, capacity: dat.count)
