Skip to content

net/http: add InactivityTimeout to http.DefaultClient #22982

Closed
@knightXun

Description

@knightXun

var DefaultClient = &Client{}

Look at two code:
server.go:

package main

import "net/http"
import (
	"time"
	"fmt"
)


func main() {
	http.HandleFunc("/test", test)
	http.ListenAndServe(":9999", nil)
}

func test(w http.ResponseWriter, r *http.Request){
	fmt.Println("test func")
	time.Sleep(100000000000000)
}

client.go

package main

import (
	"net/http"
	"fmt"
)

func main() {
	resp, err := http.Get("http://127.0.0.1:9999/test")
	if err != nil {
		fmt.Println(err.Error())
	} else {
		fmt.Println(resp.StatusCode)
	}
}

when we run client.go, it will stuck. please notice it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions