         }
         responseString.append("\r\n")
         connection.write(string: responseString) {
-            _ in
+            sent in
+            guard sent > 0 else {
+                self.completedCallback = nil
+                self.connection.close()
+                return
+            }
             self.push(callback: callback)
         }
     }

    func pushHeaders(callback: (Bool) -> ()) {
        wroteHeaders = true
        if isKeepAlive {
            addHeader(.connection, value: "keep-alive")
        }
        if isStreaming {
            addHeader(.transferEncoding, value: "chunked")

            sent in
            self.bodyBytes.removeAll()
            guard bodyCount == sent else {
                self.completedCallback = nil
                self.connection.close()
                return
            }
            Threading.dispatch {
                callback(true)
