     
     func parseJSONText() throws -> (StompCommand, Set<StompHeader>, String)  {
         let data = dataUsingEncoding(NSUTF8StringEncoding)!
-        do {
-            let json = try NSJSONSerialization.JSONObjectWithData(data, options: .AllowFragments) as! [String]
-            let components = json.first!.componentsSeparatedByString("\n")
-            let command = StompCommand(rawValue: components.first!)!
-            
-            var headers: Set<StompHeader> = []
-            var body = ""
-            var isBody = false
-            for index in 1 ..< components.count {
-                let component = components[index]
-                if isBody {
-                    body += component
-                    if body.hasSuffix("\0") {
-                        body = body.stringByReplacingOccurrencesOfString("\0", withString: "")
+        let json = try NSJSONSerialization.JSONObjectWithData(data, options: .AllowFragments) as! [String]
+        let components = json.first!.componentsSeparatedByString("\n")
+        let command = StompCommand(rawValue: components.first!)!
+        
+        var headers: Set<StompHeader> = []
+        var body = ""
+        var isBody = false
+        for index in 1 ..< components.count {
+            let component = components[index]
+            if isBody {
+                body += component
+                if body.hasSuffix("\0") {
+                    body = body.stringByReplacingOccurrencesOfString("\0", withString: "")
+                }
+            } else {
+                if component == "" {
+                    isBody = true
+                } else {
+                    let parts = component.componentsSeparatedByString(":")
+                    guard let key = parts.first, let value = parts.last else {
+                        continue
                     }
-                } else {
-                    if component == "" {
-                        isBody = true
-                    } else {
-                        let parts = component.componentsSeparatedByString(":")
-                        if let header = StompHeader.generateHeader(parts.first!, value: parts.last!) {
-                            headers.insert(header)
-                        }
-                    }
+                    let header = try StompHeader(key: key, value: value)
+                    headers.insert(header)
                 }
             }
-            return (command, headers, body)
-        } catch let error as NSError {
-            throw error
-        }
-    }
-    
-}
+        }
+        return (command, headers, body)
+    }
+    
+}

    }
    
    var message: String {
        let filteredHeaders = headers.filter { header -> Bool in
            return header.isMessage
        }
        
        if filteredHeaders.isEmpty {
            return ""
        } else {
            return filteredHeaders.first!.value
        }
    }
    
    var destination: String {
        let filteredHeaders = headers.filter { header -> Bool in
            return header.isDestination
        }
        
        if filteredHeaders.isEmpty {
            return ""
        } else {
            return filteredHeaders.first!.value
        }
    }
    
    // MARK: - Private Properties
    private let lineFeed = "\u{0A}"
    private let nullChar = "\u{00}"
    private(set) var type: StompResponseType?
    private(set) var command: StompCommand
    private(set) var headers: Set<StompHeader>

        return key.hashValue
    }
    
    // MARK: - Initializers
    init(key: String, value: String) throws {
        switch key {
        case "version":
            self = .Version(version: value)
        case "subscription":
            self = .Subscription(subId: value)
        case "message-id":
            self = .MessageId(id: value)
        case "content-length":
            self = .ContentLength(length: value)
        case "message":
            self = .Message(message: value)
        case "destination":
            self = .Destination(path: value)
        case "heart-beat":
            self = .HeartBeat(value: value)
        default:
            throw NSError(domain: "com.shenghuawu.error", code: 999, userInfo: [NSLocalizedDescriptionKey : "Received header key-value pair is undefined."])
        }
    }
    
