Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: request not really canceled #32685

Closed
gbbr opened this issue Jun 19, 2019 · 2 comments
Closed

net/http: request not really canceled #32685

gbbr opened this issue Jun 19, 2019 · 2 comments

Comments

@gbbr
Copy link
Member

gbbr commented Jun 19, 2019

Using the code in this snippet: https://play.golang.org/p/oSK66nc3I_S with go1.12 does not have the expected outcome. I have tried my best to find the documentation explaining exactly how request cancelation works all the way from client to server, as well as tried to look at the code, but it was a bit difficult to figure out.

When a request is canceled by the client, and it returns an error that a request was canceled (context.Canceled), is it wrong to have the expectation that server did not read the body and processed it? I'd expect a canceled request to mean exactly that. Otherwise what is really canceled here?

Lastly, if the above is not correct, then I'd at least expect a way for the server to tell that the request was canceled.

  • Is there any way to cancel a request in such a way that if the request body was already sent, it will be too late to do so?
  • If the client returns "context canceled", that should mean that the request did not reach the server?

This seems like a bug to me. If a request has completed, the "canceled" error should never be returned.

@gbbr gbbr added the Question label Jun 19, 2019
@ianlancetaylor
Copy link
Contributor

You will probably get a better and faster answer on a forum. See https://golang.org/wiki/Questions.

@gbbr
Copy link
Member Author

gbbr commented Jun 20, 2019

Ok. I will try. I was wondering if it’s a bug...

@gbbr gbbr closed this as completed Jun 20, 2019
@golang golang locked and limited conversation to collaborators Jun 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants