Skip to content

Commit

Permalink
Add a comment related to hijacking, ref #124
Browse files Browse the repository at this point in the history
  • Loading branch information
xyproto committed Sep 30, 2024
1 parent 57aa672 commit 0eb799a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion engine/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,27 @@ func (ac *Config) LoadBasicWeb(w http.ResponseWriter, req *http.Request, L *lua.
// Close the connection.
// Works for both HTTP and HTTP/2 now, ref: https://github.com/golang/go/issues/20977
w.Header().Add("Connection", "close")
// Flush, if possible

// Flush, if a flush function is available
if flushFunc != nil {
flushFunc()
}

// Stop Lua functions from writing more to this client
req.Close = true

// TODO: Set up the HTTP/QUIC/HTTP/2 Server structs with a ConnContext
// field and then fetch the connection from the req.Context()
// and use it here for closing the connection.

// Hijack the connection (does not work with fasthttp!)
//if hijacker, ok := w.(http.Hijacker); ok { // success
// if conn, buf, err := hijacker.Hijack(); err == nil { // success
// buf.Flush()
// conn.Close() // Close the hijacked connection
// }
//}

return 0 // number of results
}))

Expand Down

0 comments on commit 0eb799a

Please sign in to comment.