gpt4 book ai didi

swift - (错误域=NSPOSIXErrorDomain代码=100 "Protocol error"

转载 作者:行者123 更新时间:2023-11-28 07:50:45 25 4
gpt4 key购买 nike

我正在使用 Alamofire,与 HTTP 一起使用没有问题,但是当我将协议(protocol) HTTP 更改为 HTTPS 时出现以下问题

Error Domain=NSPOSIXErrorDomain Code=100 "Protocol error" UserInfo={NSErrorPeerAddressKey={length = 16, capacity = 16, bytes = 0x100201bb5d5efc420000000000000000}, _kCFStreamErrorCodeKey=100, _kCFStreamErrorDomainKey=1})

我试过的鳕鱼:

public init(){}
static let shared = HTTPRequest()

func Service(method:String,path:String,
parameters:[String:String]? = nil,
requestObj:Any? = nil,
actionListener:ActionListener){

actionListener.start()
var _url = URLComponents(string: BaseURL + path)

if parameters != nil{
var queryItems = [URLQueryItem]()
for parameter in parameters!{
let queryItem = URLQueryItem(name: parameter.key, value: parameter.value)
queryItems.append(queryItem)
}
_url?.queryItems = queryItems
}
var request = URLRequest(url: (_url?.url)!)

request.httpMethod = method
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
if MobileConstants.AccessToken != nil{
request.setValue(MobileConstants.AccessToken, forHTTPHeaderField:"Authorization")
request.setValue(MobileConstants.LoginResponse.user.userName, forHTTPHeaderField: "UserName")
}
request.setValue("iOS", forHTTPHeaderField: "ClientToken")
request.setValue("en-US", forHTTPHeaderField: "Language")
if(requestObj != nil){
let json = JSONSerializer.toJson(requestObj!)
request.httpBody = json.data(using: .utf8)
}

Alamofire.request(request).responseJSON {
response in
if(response.result.isSuccess){
actionListener.success(from: path, data: response.result.value!)
}else{
actionListener.fail()
print(response.error)
print(response.result.error)
}
}
}

最佳答案

这不是一个根本的解决方案,我用...解决了它

将以下内容添加到 apache 的 httpd.conf

Header unset Upgrade

并重启

关于swift - (错误域=NSPOSIXErrorDomain代码=100 "Protocol error",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49783791/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com