0001 import Nest 0002 0003 0004 public struct Request : RequestType, CustomStringConvertible, CustomDebugStringConvertible { 0005 public var method:String 0006 public var path
Request.swift:18 return "\(method) \(path)"Request.swift:22 let request = ["\(method) \(path)"] + headers.map { "\($0) \($1)" }:String 0007 public var headers:[Header] 0008 public var body:String? 0009 0010 public init(method:String, path:String, headers:[Header]? = nil, body:String? = nil) { 0011 self.method = method 0012 self.path = path 0013 self.headers = headers ?? [] 0014 self.body = body 0015 } 0016 0017 public var description:String { 0018 return "\(method) \(path)" 0019 } 0020 0021 public var debugDescription:String { 0022 let request = ["\(method) \(path)"] + headers.map { "\($0) \($1)" } 0023 return request.joinWithSeparator("\n") 0024 } 0025 } 0026 0027 0028 extension RequestType { 0029 public subscript(header: String) -> String? { 0030 get { 0031 return headers.filter { $0.0 == header }.first?.1 0032 } 0033 } 0034 0035 /// Returns the Host header 0036 public var host:String? { 0037 return self["Host"] 0038 } 0039 0040 /// Returns the Content-Type header 0041 public var contentType:String? { 0042 return self["Content-Type"] 0043 } 0044 0045 /// Returns the Content-Length header 0046 public var contentLength:Int? { 0047 if let contentLength = self["Content-Length"] { 0048 return Int(contentLength) 0049 } 0050 0051 return nil 0052 } 0053 0054 /// Returns the Accept header 0055 public var accept:String? { 0056 return self["Accept"] 0057 } 0058 0059 /// Returns the Authorization header 0060 public var authorization:String? { 0061 return self["Authorization"] 0062 } 0063 } 0064
Request.swift:18 return "\(method) \(path)"Request.swift:22 let request = ["\(method) \(path)"] + headers.map { "\($0) \($1)" }