                 if !final {
                     break
                 }
-                strm.avail_in = CUnsignedInt(inflateEnd.count)
+                strm.avail_in = CUnsignedInt(inflateEndSize)
                 strm.next_in = UnsafePointer<UInt8>(inflateEnd)
             }
             while true {

        if ret != 0 {
            return nil
        }
    }
    deinit{
        _ = inflateEndG(&strm)
        free(buffer)
    }
    func inflate(_ bufin : UnsafePointer<UInt8>, length : Int, final : Bool) throws -> (p : UnsafeMutablePointer<UInt8>, n : Int){
        var buf = buffer

        for i in 0 ..< 4 {
            keyb[i] = arc4random()
        }
        let rkey = Data(bytes: keyb, count: 16).base64EncodedString(options: NSData.Base64EncodingOptions(rawValue: 0))
        reqs += "Sec-WebSocket-Key: \(rkey)\r\n"
        reqs += "\r\n"
        var header = [UInt8]()
