0001    import Foundation
0002    
0003    /**
0004        Requests contains data sent from a client to the
0005        web server such as method, parameters, and data.
0006    */
0007    public class Request
Application+Route.swift:18
        let method: Request.Method
Application+Route.swift:20
        let handler: Request.Handler
Application+Route.swift:23
        public typealias Handler = Request throws -> ResponseConvertible
Application+Route.swift:25
        init(method: Request.Method, path: String, handler: Request.Handler) {
Application+Route.swift:25
        init(method: Request.Method, path: String, handler: Request.Handler) {
Application+Route.swift:105
    public final func add(method: Request.Method, path: String, handler: Route.Handler) {
Application.swift:139
	public func serverDriverDidReceiveRequest(request: Request) -> Response {
Application.swift:140
		var handler: Request.Handler
Branch.swift:38
    private var handler: Request.Handler?
Branch.swift:58
    init(name: String, handler: Request.Handler? = nil) {
Branch.swift:72
    func handle(request: Request, comps: CompatibilityGenerator<String>) -> Request.Handler? {
Branch.swift:72
    func handle(request: Request, comps: CompatibilityGenerator<String>) -> Request.Handler? {
Branch.swift:97
    func extendBranch(generator: CompatibilityGenerator<String>, handler: Request.Handler) {
BranchRouter.swift:16
    private final var tree: [Host : [Request.Method : Branch]] = [:]
BranchRouter.swift:20
    public final func route(request: Request) -> Request.Handler? {
BranchRouter.swift:20
    public final func route(request: Request) -> Request.Handler? {
BranchRouter.swift:36
    public final func register(hostname hostname: String?, method: Request.Method, path: String, handler: Request.Handler) {
BranchRouter.swift:36
    public final func register(hostname hostname: String?, method: Request.Method, path: String, handler: Request.Handler) {
Controller.swift:9
	func index(request: Request) throws -> ResponseConvertible
Controller.swift:12
    func store(request: Request) throws -> ResponseConvertible
Controller.swift:15
    func show(request: Request) throws -> ResponseConvertible
Controller.swift:18
    func update(request: Request) throws -> ResponseConvertible
Controller.swift:21
    func destroy(request: Request) throws -> ResponseConvertible
Middleware.swift:19
    static func handle(handler: Request.Handler) -> Request.Handler
Middleware.swift:19
    static func handle(handler: Request.Handler) -> Request.Handler
Request.swift:20
    public typealias Handler = ((request: Request) throws -> Response)
Request.swift:66
        self.cookies = Request.parseCookies(headers["cookie"])
Request.swift:69
        let query = Request.parseQueryData(path)
RequestData+Target.swift:28
public extension Request {
RequestFormExtension.swift:33
extension Request {
RequestFormExtension.swift:136
            if value > Request.CR {
RequestFormExtension.swift:139
            if value == Request.NL {
RequestFormExtension.swift:158
                if body.last == Request.NL {
RequestFormExtension.swift:161
                if body.last == Request.CR {
RouterDriver.swift:4
    func route(request: Request) -> Request.Handler?
RouterDriver.swift:4
    func route(request: Request) -> Request.Handler?
RouterDriver.swift:5
    func register(hostname hostname: String?, method: Request.Method, path: String, handler: Request.Handler)
RouterDriver.swift:5
    func register(hostname hostname: String?, method: Request.Method, path: String, handler: Request.Handler)
ServerDriver.swift:11
    func serverDriverDidReceiveRequest(request: Request) -> Response
Session.swift:24
	public static func start(request: Request) {
Session.swift:35
	public static func close(request request: Request, response: Response) {
SessionMiddleware.swift:3
    static func handle(handler: Request.Handler) -> Request.Handler {
SessionMiddleware.swift:3
    static func handle(handler: Request.Handler) -> Request.Handler {
SocketParser.swift:18
        let method: Request.Method
SocketParser.swift:34
            self.method = Request.Method(rawValue: requestLineWords[0]) ?? .Unknown
SocketParser.swift:40
    func readHttpRequest(socket: Socket) throws -> Request {
SocketParser.swift:60
        return Request(method: requestLine.method, path: requestLine.path, address: address, headers: headers, body: body)
Vapor+JSON.swift:26
extension Request {
{ 0008 0009 ///Available HTTP Methods 0010 public enum Method
Application+Route.swift:18
        let method: Request.Method
Application+Route.swift:25
        init(method: Request.Method, path: String, handler: Request.Handler) {
Application+Route.swift:105
    public final func add(method: Request.Method, path: String, handler: Route.Handler) {
BranchRouter.swift:16
    private final var tree: [Host : [Request.Method : Branch]] = [:]
BranchRouter.swift:36
    public final func register(hostname hostname: String?, method: Request.Method, path: String, handler: Request.Handler) {
Request.swift:23
    public let method: Method
Request.swift:60
    public init(method: Method, path: String, address: String?, headers: [String: String], body: [UInt8]) {
RouterDriver.swift:5
    func register(hostname hostname: String?, method: Request.Method, path: String, handler: Request.Handler)
SocketParser.swift:18
        let method: Request.Method
SocketParser.swift:34
            self.method = Request.Method(rawValue: requestLineWords[0]) ?? .Unknown
: String { 0011 case Get
Application+Route.swift:38
        self.add(.Get, path: path, handler: handler)
= "GET" 0012 case Post
Application+Route.swift:42
        self.add(.Post, path: path, handler: handler)
= "POST" 0013 case Put
Application+Route.swift:46
        self.add(.Put, path: path, handler: handler)
= "PUT" 0014 case Patch
Application+Route.swift:50
        self.add(.Patch, path: path, handler: handler)
= "PATCH" 0015 case Delete
Application+Route.swift:54
        self.add(.Delete, path: path, handler: handler)
= "DELETE" 0016 case Options
Application+Route.swift:58
        self.add(.Options, path: path, handler: handler)
= "OPTIONS" 0017 case Unknown
SocketParser.swift:27
                self.method = .Unknown
SocketParser.swift:34
            self.method = Request.Method(rawValue: requestLineWords[0]) ?? .Unknown
= "x" 0018 } 0019 0020 public typealias Handler
Application+Route.swift:20
        let handler: Request.Handler
Application+Route.swift:25
        init(method: Request.Method, path: String, handler: Request.Handler) {
Application.swift:140
		var handler: Request.Handler
Branch.swift:38
    private var handler: Request.Handler?
Branch.swift:58
    init(name: String, handler: Request.Handler? = nil) {
Branch.swift:72
    func handle(request: Request, comps: CompatibilityGenerator<String>) -> Request.Handler? {
Branch.swift:97
    func extendBranch(generator: CompatibilityGenerator<String>, handler: Request.Handler) {
BranchRouter.swift:20
    public final func route(request: Request) -> Request.Handler? {
BranchRouter.swift:36
    public final func register(hostname hostname: String?, method: Request.Method, path: String, handler: Request.Handler) {
Middleware.swift:19
    static func handle(handler: Request.Handler) -> Request.Handler
Middleware.swift:19
    static func handle(handler: Request.Handler) -> Request.Handler
RouterDriver.swift:4
    func route(request: Request) -> Request.Handler?
RouterDriver.swift:5
    func register(hostname hostname: String?, method: Request.Method, path: String, handler: Request.Handler)
SessionMiddleware.swift:3
    static func handle(handler: Request.Handler) -> Request.Handler {
SessionMiddleware.swift:3
    static func handle(handler: Request.Handler) -> Request.Handler {
= ((request: Request) throws -> Response) 0021 0022 ///HTTP Method used for request. 0023 public let method
BranchRouter.swift:25
        guard let branch = root?[request.method] else {
Request.swift:61
        self.method = method
: Method 0024 0025 ///Query data from the path, or POST data from the body (depends on `Method`). 0026 public let data
Request.swift:70
        self.data = Data(query: query, bytes: body)
: Data 0027 0028 ///Browser stored data sent with every server request 0029 public let cookies
Request.swift:66
        self.cookies = Request.parseCookies(headers["cookie"])
Session.swift:25
		if let key = request.cookies["vapor-session"] {
: [String: String] 0030 0031 ///Path requested from server, not including hostname. 0032 public let path
Application.swift:147
			let filePath = self.dynamicType.workDir + "Public" + request.path
BranchRouter.swift:30
        let generator = request.path.pathComponentGenerator()
Request.swift:62
        self.path = path.split(separator: "?")[0]
: String 0033 0034 ///Information or metadata about the `Request`. 0035 public let headers
Request.swift:54
        if let value = self.headers["connection"] {
Request.swift:64
        self.headers = headers
RequestFormExtension.swift:35
        guard let contentTypeHeader = headers["content-type"] else {
RequestFormExtension.swift:83
        guard let contentTypeHeader = headers["content-type"] else {
: [String: String] 0036 0037 ///Content of the `Request`. 0038 public let body
Request.swift:65
        self.body = body
RequestFormExtension.swift:42
        return String.fromUInt8(body).split("&").map { (param: String) -> (String, String) in
RequestFormExtension.swift:98
            return parseMultiPartFormData(body, boundary: "--\(boundary)")
Vapor+JSON.swift:32
        return try? Json.deserialize(body)
: [UInt8] 0039 0040 ///Address from which the `Request` originated. 0041 public let address
Request.swift:63
        self.address = address
: String? 0042 0043 ///URL parameters (ex: `:id`). 0044 public var parameters
Branch.swift:80
            request.parameters[wildcard.name] = key.stringByRemovingPercentEncoding
: [String: String] = [:] 0045 0046 ///Server stored information related from session cookie. 0047 public var session
Session.swift:27
				request.session = session
Session.swift:29
				request.session.key = key
Session.swift:30
				self.driver.sessions[key] = request.session
Session.swift:36
		if let key = request.session.key {
: Session = Session() 0048 0049 ///Requested hostname 0050 public let hostname
BranchRouter.swift:22
        let root = tree[request.hostname] ?? tree["*"]
Request.swift:67
        self.hostname = headers["host"] ?? "*"
: String 0051 0052 ///Whether the connection should be kept open for multiple Requests 0053 var supportsKeepAlive
SocketServer.swift:102
            var keepConnection = request.supportsKeepAlive
: Bool { 0054 if let value = self.headers["connection"] { 0055 return "keep-alive" == value.trim() 0056 } 0057 return false 0058 } 0059 0060 public init
SocketParser.swift:60
        return Request(method: requestLine.method, path: requestLine.path, address: address, headers: headers, body: body)
(method: Method, path: String, address: String?, headers: [String: String], body: [UInt8]) { 0061 self.method = method 0062 self.path = path.split(separator: "?")[0] 0063 self.address = address 0064 self.headers = headers 0065 self.body = body 0066 self.cookies = Request.parseCookies(headers["cookie"]) 0067 self.hostname = headers["host"] ?? "*" 0068 0069 let query = Request.parseQueryData(path) 0070 self.data = Data(query: query, bytes: body) 0071 0072 Log.verbose("Received \(method) request for \(path)") 0073 } 0074 0075 /** 0076 Cookies are sent to the server as `key=value` pairs 0077 separated by semicolons. 0078 0079 - returns: String dictionary of parsed cookies. 0080 */ 0081 class func parseCookies
Request.swift:66
        self.cookies = Request.parseCookies(headers["cookie"])
(string: String?) -> [String: String] { 0082 var cookies: [String: String] = [:] 0083 0084 guard let string = string else { 0085 return cookies 0086 } 0087 0088 let cookieTokens = string.split(";") 0089 for cookie in cookieTokens { 0090 let cookieArray = cookie.split("=") 0091 0092 if cookieArray.count == 2 { 0093 let key = cookieArray[0].split(" ").joinWithSeparator("") 0094 cookies[key] = cookieArray[1] 0095 } 0096 } 0097 0098 return cookies 0099 } 0100 0101 /** 0102 Query data is information appended to the URL path 0103 as `key=value` pairs separated by `&` after 0104 an initial `?` 0105 0106 - returns: String dictionary of parsed Query data 0107 */ 0108 static func parseQueryData
Request.swift:69
        let query = Request.parseQueryData(path)
(string: String) -> [String: String] { 0109 0110 var urlParts = string.split("?") 0111 if urlParts.count >= 2 { 0112 return self.parseData(urlParts[1]) 0113 } 0114 0115 return [:] 0116 } 0117 0118 /** 0119 Parses `key=value` pair data separated by `&`. 0120 0121 - returns: String dictionary of parsed data 0122 */ 0123 static func parseData
Request.swift:112
            return self.parseData(urlParts[1])
(string: String) -> [String: String] { 0124 var data: [String: String] = [:] 0125 0126 for pair in string.split("&") { 0127 let tokens = pair.split(1, separator: "=") 0128 0129 if let name = tokens.first, value = tokens.last { 0130 data[name.removePercentEncoding()] = value.removePercentEncoding() 0131 } 0132 } 0133 0134 return data 0135 } 0136 0137 } 0138