Swiftpack.co - zhtut/SSURLSession as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by zhtut.
zhtut/SSURLSession 0.3.0
⭐️ 6
🕓 33 weeks ago
.package(url: "https://github.com/zhtut/SSURLSession.git", from: "0.3.0")




let resolve = "\(host):443:\(ip)"
setValue(resolve, forHTTPHeaderField: "resolve")


let connectTo = "\(host):443:\(ip):443"
setValue(connectTo, forHTTPHeaderField: "connectTo")


目前发现上面两个字段都可以实现强制解析的功能 所以用上面那个字段就可以实现需求了 需要注意的是,ip服务器需要包含host域名的证书,这样才能认证通过



.package(url: "https://github.com/zhtut/SSURLSession.git", from: "0.1.0")


pod 'SSURLSession'


import SSURLSession

let host = "www.baidu.com"
let urlStr = "https://\(host)"
let url = URL(string: urlStr)!
var req = URLRequest(url: url)
// direct ip
let ip = ""
let resolve = "\(host):443:\(ip)"
// add dns resolve
req.setValue(resolve, forHTTPHeaderField: "resolve")
let task = SSURLSession.URLSession.shared.dataTask(with: req, completionHandler: { data, resp, error in
    if let data {
    } else {
        if let error {
            print("error: \(error)")


由于swift foundation core lib 未完全完成,有部分功能是不正常的, 但至少比CFNetwork和直接使用libcurl更成熟


  • URL: Networking primitives

    The classes in this group provide functionality for manipulating URLs and paths via a common model object. The group also has classes for creating and receiving network connections.

    Entity Name Status Test Coverage Notes
    URLAuthenticationChallenge Unimplemented None
    URLCache Unimplemented None
    URLCredential Complete Incomplete
    URLCredentialStorage Unimplemented None
    NSURLError* Complete N/A
    URLProtectionSpace Unimplemented None
    URLProtocol Unimplemented None
    URLProtocolClient Unimplemented None
    NSURLRequest Complete Incomplete
    NSMutableURLRequest Complete Incomplete
    URLResponse Complete Substantial
    NSHTTPURLResponse Complete Substantial
    NSURL Mostly Complete Substantial Resource values remain unimplemented
    NSURLQueryItem Complete N/A
    URLResourceKey Complete N/A
    URLFileResourceType Complete N/A
    URL Complete Incomplete
    URLResourceValues Complete N/A
    URLComponents Complete Incomplete
    URLRequest Complete None
    HTTPCookie Complete Incomplete
    HTTPCookiePropertyKey Complete N/A
    HTTPCookieStorage Mostly Complete Substantial
    Host Complete None
    Configuration N/A N/A For internal use only
    EasyHandle N/A N/A For internal use only
    HTTPBodySource N/A N/A For internal use only
    HTTPMessage N/A N/A For internal use only
    libcurlHelpers N/A N/A For internal use only
    MultiHandle N/A N/A For internal use only
    URLSession Mostly Complete Incomplete invalidation, resetting, flushing, getting tasks, and others remain unimplemented
    URLSessionConfiguration Mostly Complete Incomplete ephemeral and background(withIdentifier:) remain unimplemented
    URLSessionDelegate Complete N/A
    URLSessionTask Mostly Complete Incomplete cancel(), createTransferState(url:) with streams, and others remain unimplemented
    URLSessionDataTask Complete Incomplete
    URLSessionUploadTask Complete None
    URLSessionDownloadTask Incomplete Incomplete
    URLSessionStreamTask Unimplemented None
    TaskRegistry N/A N/A For internal use only
    TransferState N/A N/A For internal use only


Stars: 6
Last commit: 5 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics