0001 // Response.swift 0002 // 0003 // Copyright (c) 2014–2016 Alamofire Software Foundation (http://alamofire.org/) 0004 // 0005 // Permission is hereby granted, free of charge, to any person obtaining a copy 0006 // of this software and associated documentation files (the "Software"), to deal 0007 // in the Software without restriction, including without limitation the rights 0008 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 0009 // copies of the Software, and to permit persons to whom the Software is 0010 // furnished to do so, subject to the following conditions: 0011 // 0012 // The above copyright notice and this permission notice shall be included in 0013 // all copies or substantial portions of the Software. 0014 // 0015 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 0016 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 0017 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 0018 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 0019 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 0020 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 0021 // THE SOFTWARE. 0022 0023 import Foundation 0024 0025 /// Used to store all response data returned from a completed `Request`. 0026 public struct Response<Value
Response.swift:71 extension Response: CustomStringConvertible {Response.swift:81 extension Response: CustomDebugStringConvertible {ResponseSerialization.swift:111 completionHandler: Response<T.SerializedObject, T.ErrorObject> -> Void)ResponseSerialization.swift:132 let response = Response<T.SerializedObject, T.ErrorObject>(ResponseSerialization.swift:179 public func responseData(completionHandler: Response<NSData, NSError> -> Void) -> Self {ResponseSerialization.swift:244 completionHandler: Response<String, NSError> -> Void)ResponseSerialization.swift:300 completionHandler: Response<AnyObject, NSError> -> Void)ResponseSerialization.swift:358 completionHandler: Response<AnyObject, NSError> -> Void), Error
Response.swift:37 public let result: Result<Value, Error>Response.swift:58 result: Result<Value, Error>,: ErrorType> { 0027 /// The URL request sent to the server. 0028 public let request
Response.swift:37 public let result: Result<Value, Error>Response.swift:58 result: Result<Value, Error>,: NSURLRequest? 0029 0030 /// The server's response to the URL request. 0031 public let response
Response.swift:61 self.request = requestResponse.swift:87 output.append(request != nil ? "[Request]: \(request!)" : "[Request]: nil")Response.swift:87 output.append(request != nil ? "[Request]: \(request!)" : "[Request]: nil"): NSHTTPURLResponse? 0032 0033 /// The data returned by the server. 0034 public let data
Response.swift:62 self.response = responseResponse.swift:88 output.append(response != nil ? "[Response]: \(response!)" : "[Response]: nil")Response.swift:88 output.append(response != nil ? "[Response]: \(response!)" : "[Response]: nil"): NSData? 0035 0036 /// The result of response serialization. 0037 public let result
Response.swift:63 self.data = dataResponse.swift:89 output.append("[Data]: \(data?.length ?? 0) bytes"): Result<Value, Error> 0038 0039 /// The timeline of the complete lifecycle of the `Request`. 0040 public let timeline
Response.swift:64 self.result = resultResponse.swift:75 return result.debugDescriptionResponse.swift:90 output.append("[Result]: \(result.debugDescription)"): Timeline 0041 0042 /** 0043 Initializes the `Response` instance with the specified URL request, URL response, server data and response 0044 serialization result. 0045 0046 - parameter request: The URL request sent to the server. 0047 - parameter response: The server's response to the URL request. 0048 - parameter data: The data returned by the server. 0049 - parameter result: The result of response serialization. 0050 - parameter timeline: The timeline of the complete lifecycle of the `Request`. Defaults to `Timeline()`. 0051 0052 - returns: the new `Response` instance. 0053 */ 0054 public init( 0055 request: NSURLRequest?, 0056 response: NSHTTPURLResponse?, 0057 data: NSData?, 0058 result: Result<Value, Error>, 0059 timeline: Timeline = Timeline()) 0060 { 0061 self.request = request 0062 self.response = response 0063 self.data = data 0064 self.result = result 0065 self.timeline = timeline 0066 } 0067 } 0068 0069 // MARK: - CustomStringConvertible 0070 0071 extension Response: CustomStringConvertible { 0072 /// The textual representation used when written to an output stream, which includes whether the result was a 0073 /// success or failure. 0074 public var description: String { 0075 return result.debugDescription 0076 } 0077 } 0078 0079 // MARK: - CustomDebugStringConvertible 0080 0081 extension Response: CustomDebugStringConvertible { 0082 /// The debug textual representation used when written to an output stream, which includes the URL request, the URL 0083 /// response, the server data and the response serialization result. 0084 public var debugDescription: String { 0085 var output: [String] = [] 0086 0087 output.append(request != nil ? "[Request]: \(request!)" : "[Request]: nil") 0088 output.append(response != nil ? "[Response]: \(response!)" : "[Response]: nil") 0089 output.append("[Data]: \(data?.length ?? 0) bytes") 0090 output.append("[Result]: \(result.debugDescription)") 0091 output.append("[Timeline]: \(timeline.debugDescription)") 0092 0093 return output.joinWithSeparator("\n") 0094 } 0095 } 0096
Response.swift:65 self.timeline = timelineResponse.swift:91 output.append("[Timeline]: \(timeline.debugDescription)")