Skip to content

net/http: documentation unclear about when request body is closed #33244

Closed
@gbbr

Description

@gbbr

It is currently possible for a request body to be read, even after http.Client.Do returns. This can be a source of potential race conditions. It is currently unclear in the documentation that this can happen. To the contrary, the documentation is hinting at the fact that the request body will be closed after the function returns, at least to my understanding. To illustrate, the attached playground example reproduces the problem, when compiled with the -race flag:

https://play.golang.org/p/Z0t0QEawcev

The purpose of this issue is to clarify whether:

  • This is a bug?
  • Documentation can be improved?

Useful links:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions