Update Alamofire to 4.2.0 with new version of Xcode 8.1
This commit is contained in:
38
Pods/Alamofire/README.md
generated
38
Pods/Alamofire/README.md
generated
@ -55,8 +55,8 @@ In order to keep Alamofire focused specifically on core networking implementatio
|
||||
|
||||
## Requirements
|
||||
|
||||
- iOS 9.0+ / macOS 10.11+ / tvOS 9.0+ / watchOS 2.0+
|
||||
- Xcode 8.0+
|
||||
- iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+
|
||||
- Xcode 8.1+
|
||||
- Swift 3.0+
|
||||
|
||||
## Migration Guides
|
||||
@ -130,13 +130,13 @@ If you prefer not to use either of the aforementioned dependency managers, you c
|
||||
|
||||
- Open up Terminal, `cd` into your top-level project directory, and run the following command "if" your project is not initialized as a git repository:
|
||||
|
||||
```bash
|
||||
```bash
|
||||
$ git init
|
||||
```
|
||||
|
||||
- Add Alamofire as a git [submodule](http://git-scm.com/docs/git-submodule) by running the following command:
|
||||
|
||||
```bash
|
||||
```bash
|
||||
$ git submodule add https://github.com/Alamofire/Alamofire.git
|
||||
```
|
||||
|
||||
@ -158,7 +158,7 @@ $ git submodule add https://github.com/Alamofire/Alamofire.git
|
||||
|
||||
- And that's it!
|
||||
|
||||
> The `Alamofire.framework` is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.
|
||||
> The `Alamofire.framework` is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.
|
||||
|
||||
---
|
||||
|
||||
@ -199,7 +199,7 @@ Alamofire contains five different response handlers by default including:
|
||||
// Response Handler - Unserialized Response
|
||||
func response(
|
||||
queue: DispatchQueue?,
|
||||
completionHandler: @escaping (DefaultDownloadResponse) -> Void)
|
||||
completionHandler: @escaping (DefaultDataResponse) -> Void)
|
||||
-> Self
|
||||
|
||||
// Response Data Handler - Serialized into Data
|
||||
@ -240,7 +240,7 @@ The `response` handler does NOT evaluate any of the response data. It merely for
|
||||
Alamofire.request("https://httpbin.org/get").response { response in
|
||||
print("Request: \(response.request)")
|
||||
print("Response: \(response.response)")
|
||||
print("Error: \(response.data)")
|
||||
print("Error: \(response.error)")
|
||||
|
||||
if let data = response.data, let utf8Text = String(data: data, encoding: .utf8) {
|
||||
print("Data: \(utf8Text)")
|
||||
@ -331,7 +331,7 @@ By default, Alamofire treats any completed request to be successful, regardless
|
||||
Alamofire.request("https://httpbin.org/get")
|
||||
.validate(statusCode: 200..<300)
|
||||
.validate(contentType: ["application/json"])
|
||||
.response { response in
|
||||
.responseData { response in
|
||||
switch response.result {
|
||||
case .success:
|
||||
print("Validation Successful")
|
||||
@ -360,7 +360,7 @@ Alamofire.request("https://httpbin.org/get").validate().responseJSON { response
|
||||
|
||||
Response Caching is handled on the system framework level by [`URLCache`](https://developer.apple.com/reference/foundation/urlcache). It provides a composite in-memory and on-disk cache and lets you manipulate the sizes of both the in-memory and on-disk portions.
|
||||
|
||||
> By default, Alamofire leverages the shared `URLCache`. In order to customize it, see the [Session Manager Configurations](#session-manager-configurations) section.
|
||||
> By default, Alamofire leverages the shared `URLCache`. In order to customize it, see the [Session Manager Configurations](#session-manager) section.
|
||||
|
||||
### HTTP Methods
|
||||
|
||||
@ -520,7 +520,7 @@ Alamofire.request("https://httpbin.org/headers", headers: headers).responseJSON
|
||||
}
|
||||
```
|
||||
|
||||
> For HTTP headers that do not change, it is recommended to set them on the `URLSessionConfiguration` so they are automatically applied to any `URLSessionTask` created by the underlying `URLSession`. For more information, see the [Session Manager Configurations](#session-manager-configurations) section.
|
||||
> For HTTP headers that do not change, it is recommended to set them on the `URLSessionConfiguration` so they are automatically applied to any `URLSessionTask` created by the underlying `URLSession`. For more information, see the [Session Manager Configurations](#session-manager) section.
|
||||
|
||||
The default Alamofire `SessionManager` provides a default set of headers for every `Request`. These include:
|
||||
|
||||
@ -528,7 +528,7 @@ The default Alamofire `SessionManager` provides a default set of headers for eve
|
||||
- `Accept-Language`, which defaults to up to the top 6 preferred languages on the system, formatted like `en;q=1.0`, per [RFC 7231 §5.3.5](https://tools.ietf.org/html/rfc7231#section-5.3.5).
|
||||
- `User-Agent`, which contains versioning information about the current app. For example: `iOS Example/1.0 (com.alamofire.iOS-Example; build:1; iOS 10.0.0) Alamofire/4.0.0`, per [RFC 7231 §5.5.3](https://tools.ietf.org/html/rfc7231#section-5.5.3).
|
||||
|
||||
If you need to customize these headers, a custom `URLSessionManagerConfiguration` should be created, the `defaultHTTPHeaders` property updated and the configuration applied to a new `SessionManager` instance.
|
||||
If you need to customize these headers, a custom `URLSessionConfiguration` should be created, the `defaultHTTPHeaders` property updated and the configuration applied to a new `SessionManager` instance.
|
||||
|
||||
### Authentication
|
||||
|
||||
@ -603,7 +603,7 @@ Alamofire.download("https://httpbin.org/image/png").responseData { response in
|
||||
}
|
||||
```
|
||||
|
||||
> The `Alamofire.download` APIs should also be used if you need to download data while your app is in the background. For more information, please see the [Session Manager Configurations](#session-manager-configurations) section.
|
||||
> The `Alamofire.download` APIs should also be used if you need to download data while your app is in the background. For more information, please see the [Session Manager Configurations](#session-manager) section.
|
||||
|
||||
#### Download File Destination
|
||||
|
||||
@ -623,7 +623,7 @@ let destination: DownloadRequest.DownloadFileDestination = { _, _ in
|
||||
Alamofire.download(urlString, to: destination).response { response in
|
||||
print(response)
|
||||
|
||||
if response.result.isSuccess, let imagePath = response.destinationURL?.path {
|
||||
if response.error == nil, let imagePath = response.destinationURL?.path {
|
||||
let image = UIImage(contentsOfFile: imagePath)
|
||||
}
|
||||
}
|
||||
@ -672,6 +672,8 @@ Alamofire.download("https://httpbin.org/image/png")
|
||||
|
||||
If a `DownloadRequest` is cancelled or interrupted, the underlying URL session may generate resume data for the active `DownloadRequest`. If this happens, the resume data can be re-used to restart the `DownloadRequest` where it left off. The resume data can be accessed through the download response, then reused when trying to restart the request.
|
||||
|
||||
> **IMPORTANT:** On the latest release of all the Apple platforms (iOS 10, macOS 10.12, tvOS 10, watchOS 3), `resumeData` is broken on background URL session configurations. There's an underlying bug in the `resumeData` generation logic where the data is written incorrectly and will always fail to resume the download. For more information about the bug and possible workarounds, please see this Stack Overflow [post](http://stackoverflow.com/a/39347461/1342462).
|
||||
|
||||
```swift
|
||||
class ImageRequestor {
|
||||
private var resumeData: Data?
|
||||
@ -711,7 +713,7 @@ class ImageRequestor {
|
||||
|
||||
When sending relatively small amounts of data to a server using JSON or URL encoded parameters, the `Alamofire.request` APIs are usually sufficient. If you need to send much larger amounts of data from a file URL or an `InputStream`, then the `Alamofire.upload` APIs are what you want to use.
|
||||
|
||||
> The `Alamofire.upload` APIs should also be used if you need to upload data while your app is in the background. For more information, please see the [Session Manager Configurations](#session-manager-configurations) section.
|
||||
> The `Alamofire.upload` APIs should also be used if you need to upload data while your app is in the background. For more information, please see the [Session Manager Configurations](#session-manager) section.
|
||||
|
||||
#### Uploading Data
|
||||
|
||||
@ -1289,8 +1291,12 @@ class OAuth2Handler: RequestAdapter, RequestRetrier {
|
||||
.responseJSON { [weak self] response in
|
||||
guard let strongSelf = self else { return }
|
||||
|
||||
if let json = response.result.value as? [String: String] {
|
||||
completion(true, json["access_token"], json["refresh_token"])
|
||||
if
|
||||
let json = response.result.value as? [String: Any],
|
||||
let accessToken = json["access_token"] as? String,
|
||||
let refreshToken = json["refresh_token"] as? String
|
||||
{
|
||||
completion(true, accessToken, refreshToken)
|
||||
} else {
|
||||
completion(false, nil, nil)
|
||||
}
|
||||
|
Reference in New Issue
Block a user