0001 // Parser.swift 0002 // 0003 // The MIT License (MIT) 0004 // 0005 // Copyright (c) 2015 Zewo 0006 // 0007 // Permission is hereby granted, free of charge, to any person obtaining a copy 0008 // of this software and associated documentation files (the "Software"), to deal 0009 // in the Software without restriction, including without limitation the rights 0010 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 0011 // copies of the Software, and to permit persons to whom the Software is 0012 // furnished to do so, subject to the following conditions: 0013 // 0014 // The above copyright notice and this permission notice shall be included in all 0015 // copies or substantial portions of the Software. 0016 // 0017 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 0018 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 0019 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 0020 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 0021 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 0022 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 0023 // SOFTWARE. 0024 0025 import CHTTPParser 0026 0027 typealias Parser= UnsafeMutablePointer<http_parser> 0028 0029 struct ParseError
RequestParser.swift:120 func onRequestURL(parser: Parser, data: UnsafePointer<Int8>, length: Int) -> Int32 {RequestParser.swift:131 func onRequestHeaderField(parser: Parser, data: UnsafePointer<Int8>, length: Int) -> Int32 {RequestParser.swift:146 func onRequestHeaderValue(parser: Parser, data: UnsafePointer<Int8>, length: Int) -> Int32 {RequestParser.swift:171 func onRequestHeadersComplete(parser: Parser) -> Int32 {RequestParser.swift:195 func onRequestBody(parser: Parser, data: UnsafePointer<Int8>, length: Int) -> Int32 {RequestParser.swift:203 func onRequestMessageComplete(parser: Parser) -> Int32 {ResponseParser.swift:119 func onResponseStatus(parser: Parser, data: UnsafePointer<Int8>, length: Int) -> Int32 {ResponseParser.swift:130 func onResponseHeaderField(parser: Parser, data: UnsafePointer<Int8>, length: Int) -> Int32 {ResponseParser.swift:148 func onResponseHeaderValue(parser: Parser, data: UnsafePointer<Int8>, length: Int) -> Int32 {ResponseParser.swift:173 func onResponseHeadersComplete(parser: Parser) -> Int32 {ResponseParser.swift:190 func onResponseBody(parser: Parser, data: UnsafePointer<Int8>, length: Int) -> Int32 {ResponseParser.swift:197 func onResponseMessageComplete(parser: Parser) -> Int32 {: ErrorType { 0030 let description: String 0031 } 0032 0033 extension Method { 0034 init
RequestParser.swift:102 let error = ParseError(description: "\(String.fromCString(errorName)!): \(String.fromCString(errorDescription)!)")ResponseParser.swift:101 let error = ParseError(description: "\(String.fromCString(errorName)!): \(String.fromCString(errorDescription)!)")(code: Int) { 0035 switch code { 0036 case 00: self = DELETE 0037 case 01: self = GET 0038 case 02: self = HEAD 0039 case 03: self = POST 0040 case 04: self = PUT 0041 case 05: self = CONNECT 0042 case 06: self = OPTIONS 0043 case 07: self = TRACE 0044 case 08: self = COPY 0045 case 09: self = LOCK 0046 case 10: self = MKCOL 0047 case 11: self = MOVE 0048 case 12: self = PROPFIND 0049 case 13: self = PROPPATCH 0050 case 14: self = SEARCH 0051 case 15: self = UNLOCK 0052 case 16: self = BIND 0053 case 17: self = REBIND 0054 case 18: self = UNBIND 0055 case 19: self = ACL 0056 case 20: self = REPORT 0057 case 21: self = MKACTIVITY 0058 case 22: self = CHECKOUT 0059 case 23: self = MERGE 0060 case 24: self = MSEARCH 0061 case 25: self = NOTIFY 0062 case 26: self = SUBSCRIBE 0063 case 27: self = UNSUBSCRIBE 0064 case 28: self = PATCH 0065 case 29: self = PURGE 0066 case 30: self = MKCALENDAR 0067 case 31: self = LINK 0068 case 32: self = UNLINK 0069 default: self = UNKNOWN 0070 } 0071 } 0072 } 0073 0074 extension UnsafeMutablePointer { 0075 func withMemory
RequestParser.swift:173 $0.method = Method(code: Int(parser.memory.method))<R>(@noescape body: inout Memory throws -> R) rethrows -> R { 0076 return try body(&memory) 0077 } 0078 }
RequestParser.swift:121 return RequestContext(parser.memory.data).withMemory {RequestParser.swift:132 return RequestContext(parser.memory.data).withMemory {RequestParser.swift:147 return RequestContext(parser.memory.data).withMemory {RequestParser.swift:172 return RequestContext(parser.memory.data).withMemory {RequestParser.swift:204 return RequestContext(parser.memory.data).withMemory {ResponseParser.swift:120 return ResponseContext(parser.memory.data).withMemory {ResponseParser.swift:131 return ResponseContext(parser.memory.data).withMemory {ResponseParser.swift:149 return ResponseContext(parser.memory.data).withMemory {ResponseParser.swift:174 return ResponseContext(parser.memory.data).withMemory {ResponseParser.swift:191 return ResponseContext(parser.memory.data).withMemory {ResponseParser.swift:198 return ResponseContext(parser.memory.data).withMemory {