     /// Sets the pre-flush lifecycle handler and returns the previous one
     ///
     /// - Parameter newPreFlush: The new pre-flush lifecycle handler
-    public func setPreFlushHandler(_ newPreFlush: PreFlushLifecycleHandler) -> PreFlushLifecycleHandler {
-        let oldPreFlush = preFlush
-        preFlush = newPreFlush
-        return oldPreFlush
+    public func setOnEndInvoked(_ newOnEndInvoked: LifecycleHandler) -> LifecycleHandler {
+        let oldOnEndInvoked = onEndInvoked
+        onEndInvoked = newOnEndInvoked
+        return oldOnEndInvoked
     }
 
 

    var invokedSend = false

    //
    // Current pre-flush lifecycle handler
    //
    private var preFlush: PreFlushLifecycleHandler = {request, response in }

    ///
    /// Set of cookies to return with the response

    ///
    public func end() throws {

        onEndInvoked()
        
        // Sets status code if unset
        if statusCode == .unknown {
