Skip to content

Commit

Permalink
updated spec
Browse files Browse the repository at this point in the history
  • Loading branch information
daltoniam committed Dec 4, 2017
1 parent 7aa8b8e commit 754859e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 23 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
All notable changes to this project will be documented in this file.
`SwiftHTTP` adheres to [Semantic Versioning](http://semver.org/).

#### [3.0.1](https://github.com/daltoniam/SwiftHTTP/tree/3.0.1)

fixed:
[#282](https://github.com/daltoniam/SwiftHTTP/pull/282)
[#281](https://github.com/daltoniam/SwiftHTTP/pull/281)
[#280](https://github.com/daltoniam/SwiftHTTP/issues/280)


Small bug fixes.

#### [3.0.0](https://github.com/daltoniam/SwiftHTTP/tree/3.0.0)

Refactor that has a simpler design. Single framework (no more platform suffixes! e.g. SwiftHTTPOSX, SwiftHTTPTVOS, etc).
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ HTTP.GET("https://domain.com", parameters: ["hello": "there"], headers: ["header
SSL Pinning is also supported in SwiftHTTP.

```swift
var req = URLRequest(urlString: "https://domain.com")
var req = URLRequest(urlString: "https://domain.com")!
req?.timeoutInterval = 5
let task = HTTP(req!)
let task = HTTP(req)
task.security = HTTPSecurity(certs: [HTTPSSLCert(data: data)], usePublicKeys: true)
//opt.security = HTTPSecurity() //uses the .cer files in your app's bundle
task.run { (response) in
Expand All @@ -136,9 +136,9 @@ You load either a `Data` blob of your certificate or you can use a `SecKeyRef` i
SwiftHTTP supports authentication through [NSURLCredential](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURLCredential_Class/Reference/Reference.html). Currently only Basic Auth and Digest Auth have been tested.

```swift
var req = URLRequest(urlString: "https://domain.com")
req?.timeoutInterval = 5
let task = HTTP(req!)
var req = URLRequest(urlString: "https://domain.com")!
req.timeoutInterval = 5
let task = HTTP(req)
//the auth closures will continually be called until a successful auth or rejection
var attempted = false
task.auth = { challenge in
Expand All @@ -156,9 +156,9 @@ task.run { (response) in
Allow all certificates example:

```swift
var req = URLRequest(urlString: "https://domain.com")
req?.timeoutInterval = 5
let task = HTTP(req!)
var req = URLRequest(urlString: "https://domain.com")!
req.timeoutInterval = 5
let task = HTTP(req)
//the auth closures will continually be called until a successful auth or rejection
var attempted = false
task.auth = { challenge in
Expand All @@ -179,18 +179,18 @@ SwiftHTTP also has a simple queue in it!

```swift
let queue = HTTPQueue(maxSimultaneousRequest: 2)
var req = URLRequest(urlString: "https://google.com")
var req = URLRequest(urlString: "https://google.com")!
req.timeoutInterval = 5
let task = HTTP(req!)
let task = HTTP(req)
task.onFinish = { (response) in
print("item in the queue finished: \(response.URL!)")
}
queue.add(http: task) //the request will start running once added to the queue


var req2 = URLRequest(urlString: "https://apple.com")
var req2 = URLRequest(urlString: "https://apple.com")!
req2.timeoutInterval = 5
let task2 = HTTP(req2!)
let task2 = HTTP(req2)
task2.onFinish = { (response) in
print("item in the queue finished: \(response.URL!)")
}
Expand Down Expand Up @@ -382,7 +382,7 @@ To use SwiftHTTP in your project add the following 'Podfile' to your project
platform :ios, '8.0'
use_frameworks!

pod 'SwiftHTTP', '~> 3.0.0'
pod 'SwiftHTTP', '~> 3.0.1'

Then run:

Expand All @@ -404,7 +404,7 @@ $ brew install carthage
To integrate SwiftHTTP into your Xcode project using Carthage, specify it in your `Cartfile`:

```
github "daltoniam/SwiftHTTP" >= 3.0.0
github "daltoniam/SwiftHTTP" >= 3.0.1
```

### Rogue
Expand Down
2 changes: 1 addition & 1 deletion Source/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.0.0</string>
<string>3.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
12 changes: 6 additions & 6 deletions Source/Operation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,44 +211,44 @@ open class HTTP {
/**
Class method to run a GET request that handles the URLRequest and parameter encoding for you.
*/
open class func GET(_ url: String, parameters: HTTPParameterProtocol? = nil, headers: [String:String]? = nil,
@discardableResult open class func GET(_ url: String, parameters: HTTPParameterProtocol? = nil, headers: [String:String]? = nil,
requestSerializer: HTTPSerializeProtocol = HTTPParameterSerializer(), completionHandler: ((Response) -> Void)? = nil) -> HTTP? {
return Run(url, method: .GET, parameters: parameters, headers: headers, requestSerializer: requestSerializer, completionHandler: completionHandler)
}

/**
Class method to run a HEAD request that handles the URLRequest and parameter encoding for you.
*/
open class func HEAD(_ url: String, parameters: HTTPParameterProtocol? = nil, headers: [String:String]? = nil, requestSerializer: HTTPSerializeProtocol = HTTPParameterSerializer(), completionHandler: ((Response) -> Void)? = nil) -> HTTP? {
@discardableResult open class func HEAD(_ url: String, parameters: HTTPParameterProtocol? = nil, headers: [String:String]? = nil, requestSerializer: HTTPSerializeProtocol = HTTPParameterSerializer(), completionHandler: ((Response) -> Void)? = nil) -> HTTP? {
return Run(url, method: .HEAD, parameters: parameters, headers: headers, requestSerializer: requestSerializer, completionHandler: completionHandler)
}

/**
Class method to run a DELETE request that handles the URLRequest and parameter encoding for you.
*/
open class func DELETE(_ url: String, parameters: HTTPParameterProtocol? = nil, headers: [String:String]? = nil, requestSerializer: HTTPSerializeProtocol = HTTPParameterSerializer(), completionHandler: ((Response) -> Void)? = nil) -> HTTP? {
@discardableResult open class func DELETE(_ url: String, parameters: HTTPParameterProtocol? = nil, headers: [String:String]? = nil, requestSerializer: HTTPSerializeProtocol = HTTPParameterSerializer(), completionHandler: ((Response) -> Void)? = nil) -> HTTP? {
return Run(url, method: .DELETE, parameters: parameters, headers: headers, requestSerializer: requestSerializer, completionHandler: completionHandler)
}

/**
Class method to run a POST request that handles the URLRequest and parameter encoding for you.
*/
open class func POST(_ url: String, parameters: HTTPParameterProtocol? = nil, headers: [String:String]? = nil, requestSerializer: HTTPSerializeProtocol = HTTPParameterSerializer(), completionHandler: ((Response) -> Void)? = nil) -> HTTP? {
@discardableResult open class func POST(_ url: String, parameters: HTTPParameterProtocol? = nil, headers: [String:String]? = nil, requestSerializer: HTTPSerializeProtocol = HTTPParameterSerializer(), completionHandler: ((Response) -> Void)? = nil) -> HTTP? {
return Run(url, method: .POST, parameters: parameters, headers: headers, requestSerializer: requestSerializer, completionHandler: completionHandler)
}

/**
Class method to run a PUT request that handles the URLRequest and parameter encoding for you.
*/
open class func PUT(_ url: String, parameters: HTTPParameterProtocol? = nil, headers: [String:String]? = nil,
@discardableResult open class func PUT(_ url: String, parameters: HTTPParameterProtocol? = nil, headers: [String:String]? = nil,
requestSerializer: HTTPSerializeProtocol = HTTPParameterSerializer(), completionHandler: ((Response) -> Void)? = nil) -> HTTP? {
return Run(url, method: .PUT, parameters: parameters, headers: headers, requestSerializer: requestSerializer, completionHandler: completionHandler)
}

/**
Class method to run a PUT request that handles the URLRequest and parameter encoding for you.
*/
open class func PATCH(_ url: String, parameters: HTTPParameterProtocol? = nil, headers: [String:String]? = nil, requestSerializer: HTTPSerializeProtocol = HTTPParameterSerializer(), completionHandler: ((Response) -> Void)? = nil) -> HTTP? {
@discardableResult open class func PATCH(_ url: String, parameters: HTTPParameterProtocol? = nil, headers: [String:String]? = nil, requestSerializer: HTTPSerializeProtocol = HTTPParameterSerializer(), completionHandler: ((Response) -> Void)? = nil) -> HTTP? {
return Run(url, method: .PATCH, parameters: parameters, headers: headers, requestSerializer: requestSerializer, completionHandler: completionHandler)
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Request.swift
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ extension URLRequest {
let queryString = parameters.createPairs(nil).map({ (pair) in
return pair.escapedValue
}).joined(separator: "&")
if let u = self.url , queryString.characters.count > 0 {
if let u = self.url , queryString.count > 0 {
let para = u.query != nil ? "&" : "?"
self.url = URL(string: "\(u.absoluteString)\(para)\(queryString)")
}
Expand Down
2 changes: 1 addition & 1 deletion SwiftHTTP.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "SwiftHTTP"
s.version = "3.0.0"
s.version = "3.0.1"
s.summary = "Thin wrapper around NSURLSession in Swift. Simplifies HTTP requests."
s.homepage = "https://github.com/daltoniam/SwiftHTTP"
s.license = 'Apache License, Version 2.0'
Expand Down

0 comments on commit 754859e

Please sign in to comment.