         }
         return nil
     }
-
-    public func headersAsJSON() throws -> Data {
-        var headerDict: [String: String] = [:]
-        for header in headers {
-            if header.hasPrefix(method.rawValue) {
-                headerDict["uri"] = header
-                continue
-            }
-            let parts = header.components(separatedBy: ":")
-            if parts.count > 1 {
-                headerDict[parts[0]] = parts[1].trimmingCharacters(in: CharacterSet(charactersIn: " "))
-            }
-        }
-        return try JSONEncoder().encode(headerDict)
-    }
 }
 
 struct _HTTPResponse {
     enum Response: Int {
         case OK = 200
         case REDIRECT = 302
-        case BAD_REQUEST = 400
         case NOTFOUND = 404
         case METHOD_NOT_ALLOWED = 405
-        case SERVER_ERROR = 500
     }
     private let responseCode: Response
     private let headers: String

    let headers: [String]

    enum Error: Swift.Error {
        case invalidURI
        case invalidMethod
        case headerEndNotFound
    }
    
    public init(header: String) throws {
        headers = header.components(separatedBy: _HTTPUtils.CRLF)
        guard headers.count > 0 else {
            throw Error.invalidURI
        }
        let uriParts = headers[0].components(separatedBy: " ")
        guard uriParts.count > 2, let methodName = Method(rawValue: uriParts[0]) else {
            throw Error.invalidMethod
        }
        method = methodName
        uri = uriParts[1]
        body = ""
    }


        } else if req.uri.hasPrefix("/unauthorized") {
            try httpServer.respondWithUnauthorizedHeader()
        } else {
            if req.method == .GET || req.method == .POST || req.method == .PUT {
                try httpServer.respond(with: getResponse(request: req))
            }
            else {
                try httpServer.respond(with: _HTTPResponse(response: .METHOD_NOT_ALLOWED, body: "Method not allowed"))
            }
        }
    }

    func getResponse(request: _HTTPRequest) -> _HTTPResponse {
        let uri = request.uri
        if uri == "/upload" {
            let text = "Upload completed!"
            return _HTTPResponse(response: .OK, headers: "Content-Length: \(text.data(using: .utf8)!.count)", body: text)
        }

        if uri == "/country.txt" {
