mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
add ability to close connection for serve-host
This commit is contained in:
parent
e26f5d19d4
commit
0fb2da902b
@ -1 +1 @@
|
|||||||
1.1
|
1.2
|
||||||
|
@ -33,6 +33,7 @@ var (
|
|||||||
doTCP = flag.Bool("tcp", false, "Serve raw over TCP.")
|
doTCP = flag.Bool("tcp", false, "Serve raw over TCP.")
|
||||||
doUDP = flag.Bool("udp", false, "Serve raw over UDP.")
|
doUDP = flag.Bool("udp", false, "Serve raw over UDP.")
|
||||||
doHTTP = flag.Bool("http", true, "Serve HTTP.")
|
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.")
|
port = flag.Int("port", 9376, "Port number.")
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -88,6 +89,12 @@ func main() {
|
|||||||
if *doHTTP {
|
if *doHTTP {
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Printf("HTTP request from %s", r.RemoteAddr)
|
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)
|
fmt.Fprintf(w, "%s", hostname)
|
||||||
})
|
})
|
||||||
go func() {
|
go func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user