                 else {
                     response.statusCode = .badRequest
                 }
-                if let theBody = responseBody {
-                    try response.write(from: theBody)
-                }
+            }
+            if let theBody = responseBody {
+                response.headers["Content-Type"] = ["text/plain"]
+                response.headers["Content-Length"] = [String(theBody.lengthOfBytes(using: .utf8))]
+                try response.write(from: theBody)
             }
             try response.end()
         }

        do {
            if notFound {
                response.statusCode = HTTPStatusCode.notFound
                let message = "None of the protocols specified in the Upgrade header are registered"
                response.headers["Content-Type"] = ["text/plain"]
                response.headers["Content-Length"] = [String(message.characters.count)]
                try response.write(from: message)
            }
            else {
                if let theProcessor = processor, let theProtocolName = protocolName {

///  - Note: There a single instance of this struct in a server.
public struct ConnectionUpgrader {
    static var instance = ConnectionUpgrader()
    
    /// Determine if any upgraders have been registered
    static var upgradersExist: Bool {
        return ConnectionUpgrader.instance.registry.count != 0
    }
    
    private var registry = [String: ConnectionUpgradeFactory]()
    
