mirror of https://github.com/k3s-io/k3s
Merge pull request #70714 from freehan/serve-hostname-close
add ability to close connection for serve-hostpull/564/head
commit
9f75e03481
|
@ -1 +1 @@
|
|||
1.1
|
||||
1.2
|
||||
|
|
|
@ -30,10 +30,11 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
doTCP = flag.Bool("tcp", false, "Serve raw over TCP.")
|
||||
doUDP = flag.Bool("udp", false, "Serve raw over UDP.")
|
||||
doHTTP = flag.Bool("http", true, "Serve HTTP.")
|
||||
port = flag.Int("port", 9376, "Port number.")
|
||||
doTCP = flag.Bool("tcp", false, "Serve raw over TCP.")
|
||||
doUDP = flag.Bool("udp", false, "Serve raw over UDP.")
|
||||
doHTTP = flag.Bool("http", true, "Serve HTTP.")
|
||||
doClose = flag.Bool("close", false, "Close connection per each HTTP request")
|
||||
port = flag.Int("port", 9376, "Port number.")
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -88,6 +89,12 @@ func main() {
|
|||
if *doHTTP {
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
log.Printf("HTTP request from %s", r.RemoteAddr)
|
||||
|
||||
if *doClose {
|
||||
// Add this header to force to close the connection after serving the request.
|
||||
w.Header().Add("Connection", "close")
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "%s", hostname)
|
||||
})
|
||||
go func() {
|
||||
|
|
Loading…
Reference in New Issue