You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"net/http"
"strconv"
"fmt"
)
func main() {
http.HandleFunc("/", httpHandler)
http.ListenAndServe(":8001", nil)
}
func httpHandler(w http.ResponseWriter, r *http.Request) {
b, _ := strconv.ParseBool(r.URL.Query().Get("loop"))
if b {
loop()
}
fmt.Fprintf(w, "ok")
}
func loop() {
i := 0
for {
if i == 10000 {
i = 0
}
i++
}
}
1. curl http://127.0.0.1:8001/?loop=true
2. curl http://127.0.0.1:8001/?loop=false
When the loop to the CPU processing and about 8 times the request, refused to all the HTTP request.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
What did you expect to see?
The text was updated successfully, but these errors were encountered: