Skip to content

net/http: EOF error of http.Client.Do() #5312

Closed
@gopherbot

Description

@gopherbot

by yunge.fu:

When I do two http requests:

resp, err := http.Get("http://localhost/signup";)
if err != nil {
    fmt.Println("get err:", err)
}
bs, _ := ioutil.ReadAll(resp.Body)
fmt.Println("bs:", string(bs[:20]))
resp.Body.Close()

//time.Sleep(1 * time.Millisecond)

resp2, err := http.PostForm("http://localhost/signup";,
url.Values{"FirstName": {"test first name"}})
if err != nil {
    fmt.Println("PostForm err:", err)
}
resp2.Body.Close()
io.Copy(os.Stdout, resp2.Body)

The second would always get EOF error, output error:
`PostForm err: Post http://localhost/signup: EOF`

But if I make the program sleep sometime between these requests, it would be ok:
time.Sleep(1 * time.Millisecond)

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
windows7, centos6.2

Which version are you using?  (run 'go version')
1.1beta2
Please note that 1.0.3 is ok!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions