NSURLSession支持POST和GET;它是否也支持CONNECT?
如果是,那么确切的语法是什么?
谢谢!
答案 0 :(得分:0)
使用NSMutableURLRequest
设置您想要的任何HTTP方法
let session = NSURLSession()
guard let url = NSURL(string: "http://www.google.com") else {
fatalError("Error creating NSURL for http://www.google.com")
}
let request = NSMutableURLRequest(URL: url)
request.HTTPMethod = "CONNECT"
let task = session.dataTaskWithRequest(request)
task.resume()