Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(79)

Issue 11432044: code review 11432044: net/http: document NewRequest treating Reader as ReadCloser (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
9 months, 1 week ago by bradfitz
Modified:
9 months ago
Reviewers:
dsymonds, rog
CC:
golang-dev, dsymonds, rog
Visibility:
Public.

Description

net/http: document NewRequest treating Reader as ReadCloser

Patch Set 1 #

Patch Set 2 : diff -r 95e1e4bd8da9 https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r 95e1e4bd8da9 https://go.googlecode.com/hg/ #

Total comments: 1

Patch Set 4 : diff -r b5209d7289bd https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+4 lines, -0 lines) Patch
M src/pkg/net/http/request.go View 1 1 chunk +4 lines, -0 lines 0 comments Download

Messages

Total messages: 8
bradfitz
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://go.googlecode.com/hg/
9 months, 1 week ago #1
dsymonds
LGTM
9 months, 1 week ago #2
rog
LGTM except i'd like to see at least one more comment and a test for ...
9 months, 1 week ago #3
rog
It might also be nice to have a slightly clearer comment in finishRequest, e.g. // ...
9 months, 1 week ago #4
bradfitz
A client request would never be there. That comment would suggest it could and be ...
9 months ago #5
bradfitz
*** Submitted as https://code.google.com/p/go/source/detail?r=25133d85b948 *** net/http: document NewRequest treating Reader as ReadCloser R=golang-dev, dsymonds, rogpeppe ...
9 months ago #6
rog
On 17 July 2013 21:23, Brad Fitzpatrick <bradfitz@golang.org> wrote: > A client request would never ...
9 months ago #7
bradfitz
9 months ago #8
I don't want to change semantics.

It's easy enough to write an ExactlyOnceCloserReader wrapper around a
reader with an idempotent close for the rare cases where Close is delicate.

But feel free to send a doc CL for Client.Post. I forgot that even took a
Reader. That might even predate me. I also never use it.
 On Jul 18, 2013 6:44 PM, "roger peppe" <rogpeppe@gmail.com> wrote:

> On 17 July 2013 21:23, Brad Fitzpatrick <bradfitz@golang.org> wrote:
> > A client request would never be there. That comment would suggest it
> could
> > and be confusing.
> >
> > Did you just grep for Body.Close?
>
> Pretty much - yes, I misread the code, sorry.
>
> Having looked again, I think the new comment is now just wrong.
> The body is closed only if we get as far as transferWriter.WriteBody
> and even then only if we successfully write it.
>
> How is a caller supposed to know if it should close
> the body or not? The only reliable approach that I can
> see is to close the body anyway and rely on the fact that
> Close is usually idempotent. This seems wrong.
>
> Can I suggest that we ensure that the body is *always*
> closed by the documented methods, or *never*? This
> halfway house seems like a recipe for hard-to-find leaks.
>
> Also, I still think it's important that Client.Post should have
> a comment - that method doesn't even reference the Request
> type, let alone NewRequest. It's a bit much to expect
> a user without much knowledge of net/http internals to infer
> that they should look at the comment on NewRequest to
> work out that the Reader they're passing to Post might be closed.
>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld 1278:e6ce13d99bf5