| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- //
- // Response.swift
- // Swifter
- //
- // Created by Dawid Szymczak on 15/08/16.
- // Copyright © 2016 Damian Kołakowski. All rights reserved.
- //
- import Foundation
- public protocol ResponseProtocol {
- var headersArray : [String: String] { get set }
- var contentObject : AnyObject { get set }
- mutating func content() -> (contentLength: Int, contentString: String)
- func headers() -> [String: String]
- func statusCode() -> Int
- }
- public class Response: ResponseProtocol {
- public var headersArray: [String : String] = ["Server" : "Swifter \(HttpServer.VERSION)"]
- public var contentObject : AnyObject = ""
- // typealias OK = getStatusCode;()
-
- public init(contentObject: AnyObject) {
- self.contentObject = contentObject
- }
-
- public func content() -> (contentLength: Int, contentString: String) {
- let contentString = String(contentObject);
- let data = [UInt8](contentString.utf8)
- return (data.count, contentString)
- }
-
- public func headers() -> [String: String] {
- return headersArray
- }
-
- public func statusCode() -> Int {
- return HttpResponse.NotFound.statusCode()
- }
-
- public func reasonPhrase() -> String {
- return HttpResponse.NotFound.reasonPhrase()
- }
-
- public func getStatusCode() -> Int {
- return HttpResponse.NotFound.statusCode()
- }
- }
|