Latest 0.1.0
Homepage https://github.com/soutaro/SMHTTPClient
License MIT
Platforms ios 8.0, requires ARC
Authors

CI Status
Version
License
Platform

SMHTTPClient is a HTTP/1.1 client based on socket API.
Since it does not depend on NSURLSession, application transport security does not prohibit sending plain-text requests with this library.

Usage

let resolver = NameResolver(hostname: "your-server.local", port: 80)
resolver.run()
let addr = resolver.results.first!

let request = HttpRequest(address: addr, path: "/", method: .GET, header: [("Host": "your-server.local")])
request.run()

switch request.status {
  case .Completed(let code, let header, let data):
    // Success
  case .Error(let error):
    // An error occured
  case .Aborted:
    // Aborted
  default:
    // ...
}

It provides a blocking API.
When you want to cancel a running request, you should call request.abort() from another thread.

let request = HttpRequest(...)
let queue = dispatch_queue_create("abort.queue", nil)

// Timeout after 5 seconds
let delay = 5 * Double(NSEC_PER_SEC)
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(delay)), queue, {
    request.abort();
})

request.run()

// request.status will be .Aborted

Installation

SMHTTPClient is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "SMHTTPClient"

Author

Soutaro Matsumoto, [email protected]

License

SMHTTPClient is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "SMHTTPClient",
    "version": "0.1.0",
    "summary": "HTTP/1.1 client, based on socket",
    "description": "Use SMHTTPClient if you need a HTTP/1.1 access without TLS.nThis is expected for apps to be used with appliance which speaks HTTP/1.1 without TLS and Bonjour.",
    "homepage": "https://github.com/soutaro/SMHTTPClient",
    "license": "MIT",
    "authors": {
        "Soutaro Matsumoto": "[email protected]"
    },
    "source": {
        "git": "https://github.com/soutaro/SMHTTPClient.git",
        "tag": "0.1.0"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "SMHTTPClient/Classes/**/*"
}

Pin It on Pinterest

Share This