0001 /* 0002 The MIT License (MIT) 0003 0004 Copyright (c) 2015 Shun Takebayashi 0005 0006 Permission is hereby granted, free of charge, to any person obtaining a copy 0007 of this software and associated documentation files (the "Software"), to deal 0008 in the Software without restriction, including without limitation the rights 0009 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 0010 copies of the Software, and to permit persons to whom the Software is 0011 furnished to do so, subject to the following conditions: 0012 0013 The above copyright notice and this permission notice shall be included in all 0014 copies or substantial portions of the Software. 0015 0016 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 0017 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 0018 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 0019 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 0020 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 0021 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 0022 SOFTWARE. 0023 */ 0024 0025 import Nest 0026 0027 public struct HTTPRequest: RequestType { 0028 0029 public let method: String 0030 public let path: String 0031 public let proto: String 0032 public let headers: [Header] 0033 public let bodyBytes
HTTPRequestParser.swift:33 func parse<R: Reader where R.Entry == Int8>(reader: R) throws -> HTTPRequestHTTPRequestParser.swift:48 func parse<R: Reader where R.Entry == Int8>(reader: R) throws -> HTTPRequest {HTTPRequestParser.swift:99 return HTTPRequest(method: parsedMethod, path: parsedPath, version: parsedVersion, headers: headers, body: body)HTTPServer.swift:33 public typealias HTTPHandler = (HTTPRequest, HTTPResponseWriter) throws -> ()HTTPServer.swift:56 serve { (req: HTTPRequest, writer: HTTPResponseWriter) throws in: [Int8] 0034 0035 init(method: String, path: String, version: String, headers: [Header], body: [Int8]) { 0036 self.method = method 0037 self.path = path 0038 self.proto = version 0039 self.headers = headers 0040 self.bodyBytes = body 0041 } 0042 0043 public var body: String? { 0044 get { 0045 return String.fromCString(bodyBytes) 0046 } 0047 } 0048 0049 } 0050
HTTPRequest.swift:45 return String.fromCString(bodyBytes)