Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift摘要身份验证异步http客户端_Swift_Digest Authentication_Swift Nio - Fatal编程技术网

Swift摘要身份验证异步http客户端

Swift摘要身份验证异步http客户端,swift,digest-authentication,swift-nio,Swift,Digest Authentication,Swift Nio,我正在尝试在swiftNIO之上使用swift创建摘要身份验证。 最后我得到了以下错误:操作无法完成。(NIO.NIOConnectionError错误1。) 以下是我的做法: // in the delegate I create my authorizationHeader let authorizationHeader = try httpClient.execute(request: digestRequest , delegate: delegate).wait() 然后在主线程中

我正在尝试在swiftNIO之上使用swift创建摘要身份验证。 最后我得到了以下错误:操作无法完成。(NIO.NIOConnectionError错误1。)

以下是我的做法:

// in the delegate I create my authorizationHeader
let authorizationHeader =  try httpClient.execute(request: digestRequest , delegate: delegate).wait()
然后在主线程中,我将执行以下操作:

var request = try HTTPClient.Request(url: url, method: .GET)

request.headers.add(name: "Authorization: \(authorizationHeader.description)" , value: "")
print (request.headers.description)
httpClient.execute(request: request).whenComplete { result in
    switch result {
    case .failure(let error):
        print (error.localizedDescription)
    case .success(let response):
        if response.status == .ok {
            print (response.status)
        } else {
            print ("error in response")
        }
    }
}
不幸的是,我没有找到其他方法来创建标题。我必须传递“”的值,因为响应头必须是(Wikipedia):“Authorization:”然后是其余的。 下面是我的Genaated响应头的一个示例: [(“授权:摘要用户名=\“myuser\”,领域=\“Testserver\”,nonce=\“4F4L1eHYktYv6n7LR4s5yyL5uMiVgKSg\”,uri=\“\”,响应=“4bc3cdfc727bec9edebf6a55dac677a7\”,”)]

我不确定这个错误:是因为我的headerresponse,还是因为我正在从主线程创建一个新请求,而不是在我的委托中,但httpclient始终是同一个实例。如果它位于headerresponse上,则似乎无法使用异步http客户端将响应字符串直接写入标头

谢谢 阿诺德