Keyboard Shortcuts

File
u :up to issue
m :publish + mail comments
M :edit review message
j / k :jump to file after / before current file
J / K :jump to next file with a comment after / before current file
Side-by-side diff
i :toggle intra-line diffs
e :expand all comments
c :collapse all comments
s :toggle showing all comments
n / p :next / previous diff chunk or comment
N / P :next / previous comment
<Up> / <Down> :next / previous line
<Enter> :respond to / edit current comment
d :mark current comment as done
Issue
u :up to list of issues
m :publish + mail comments
j / k :jump to patch after / before current patch
o / <Enter> :open current patch in side-by-side view
i :open current patch in unified diff view
Issue List
j / k :jump to issue after / before current issue
o / <Enter> :open current issue
# : close issue
Comment/message editing
<Ctrl> + s or <Ctrl> + Enter :save comment
<Esc> :cancel edit
Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(45)
Issues Repositories Search
Open Issues | Closed Issues | All Issues | Sign in with your Google Account to create issues and add comments

Issue 44040043: code review 44040043: net/http: Return ErrNotMultipart from ParseMultipartFor...

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years ago by mattcottingham
Modified:
11 years, 9 months ago
Reviewers:
bradfitz
CC:
golang-codereviews, gobot, bradfitz, rsc
Visibility:
Public.
net/http: Return ErrNotMultipart from ParseMultipartForm if content-type isn't multipart/form-data. Add test for multipart form requests with an invalid content-type to ensure ErrNotMultipart is returned. Change ParseMultipartForm to return ErrNotMultipart when it is returned by multipartReader. Modify test for empty multipart request handling to use POST so that the body is checked. Fixes issue 6334. This is the first changeset working on multipart request handling. Further changesets could add more tests and clean up the TODO.

Patch Set 1 #

Patch Set 2 : diff -r 477af6a8e51f https://code.google.com/p/go #

Patch Set 3 : diff -r 25cd0f8e0134 https://code.google.com/p/go #

Total comments: 1

Patch Set 4 : diff -r 1849f83423ca http://code.google.com/p/go #

Patch Set 5 : diff -r 1849f83423ca http://code.google.com/p/go #

Patch Set 6 : diff -r 1849f83423ca http://code.google.com/p/go #

Created: 11 years, 10 months ago
Download [raw] [tar.bz2]
Unified diffs Side-by-side diffs Delta from patch set Stats (+49 lines, -11 lines) Patch
M src/pkg/net/http/request.go View 1 2 3 1 chunk +1 line, -3 lines 0 comments Download
M src/pkg/net/http/request_test.go View 1 2 3 4 2 chunks +48 lines, -8 lines 0 comments Download
Total messages: 17
|
mattcottingham
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go
12 years ago (2013年12月18日 20:30:35 UTC) #1
Hello golang-dev@googlegroups.com,
I'd like you to review this change to
https://code.google.com/p/go 
Sign in to reply to this message.
gobot
R=bradfitz@golang.org (assigned by rsc@google.com)
12 years ago (2013年12月19日 17:08:16 UTC) #2
R=bradfitz@golang.org (assigned by rsc@google.com)
Sign in to reply to this message.
gobot
Replacing golang-dev with golang-codereviews.
12 years ago (2013年12月20日 16:26:17 UTC) #3
Replacing golang-dev with golang-codereviews.
Sign in to reply to this message.
bradfitz
https://codereview.appspot.com/44040043/diff/40001/src/pkg/net/http/request.go File src/pkg/net/http/request.go (right): https://codereview.appspot.com/44040043/diff/40001/src/pkg/net/http/request.go#newcode784 src/pkg/net/http/request.go:784: return err This looks very intentional. If this were ...
12 years ago (2013年12月26日 20:51:11 UTC) #4
https://codereview.appspot.com/44040043/diff/40001/src/pkg/net/http/request.go
File src/pkg/net/http/request.go (right):
https://codereview.appspot.com/44040043/diff/40001/src/pkg/net/http/request.g...
src/pkg/net/http/request.go:784: return err
This looks very intentional.
If this were an acceptable change (and it might be a lot to convince us all it
is), the proper way to write this would be:
 if err != nil {
 return err
 }
But I'm not convinced this is a safe change.
See the TODO comment in parsePostForm which says how all this form parsing code
is too twisty.
Sign in to reply to this message.
mattcottingham
On 2013年12月26日 20:51:11, bradfitz wrote: > https://codereview.appspot.com/44040043/diff/40001/src/pkg/net/http/request.go > File src/pkg/net/http/request.go (right): > > https://codereview.appspot.com/44040043/diff/40001/src/pkg/net/http/request.go#newcode784 > ...
12 years ago (2013年12月27日 14:45:10 UTC) #5
On 2013年12月26日 20:51:11, bradfitz wrote:
> https://codereview.appspot.com/44040043/diff/40001/src/pkg/net/http/request.go
> File src/pkg/net/http/request.go (right):
> 
>
https://codereview.appspot.com/44040043/diff/40001/src/pkg/net/http/request.g...
> src/pkg/net/http/request.go:784: return err
> This looks very intentional.
> 
> If this were an acceptable change (and it might be a lot to convince us all it
> is), the proper way to write this would be:
> 
> if err != nil {
> return err
> }
> 
> But I'm not convinced this is a safe change.
> 
Agreed. I added a test but it's likely not sufficient by itself.
> See the TODO comment in parsePostForm which says how all this form parsing
code
> is too twisty.
Yes, I saw that when reading through. I'd like to add more tests and simplify
the call graph. Does that sound okay?
Sign in to reply to this message.
bradfitz
I do want to see this code simplified, so go for it. It will have ...
12 years ago (2013年12月27日 16:47:03 UTC) #6
I do want to see this code simplified, so go for it.
It will have to be simple, readable, documented, and well-tested. And any
weird behavior is likely frozen at this point, unfortunately.
On Dec 27, 2013 6:45 AM, <MattCottingham@gmail.com> wrote:
> On 2013年12月26日 20:51:11, bradfitz wrote:
>
> https://codereview.appspot.com/44040043/diff/40001/src/
> pkg/net/http/request.go
>
>> File src/pkg/net/http/request.go (right):
>>
>
>
> https://codereview.appspot.com/44040043/diff/40001/src/
> pkg/net/http/request.go#newcode784
>
>> src/pkg/net/http/request.go:784: return err
>> This looks very intentional.
>>
>
> If this were an acceptable change (and it might be a lot to convince
>>
> us all it
>
>> is), the proper way to write this would be:
>>
>
> if err != nil {
>> return err
>> }
>>
>
> But I'm not convinced this is a safe change.
>>
>
>
> Agreed. I added a test but it's likely not sufficient by itself.
>
> See the TODO comment in parsePostForm which says how all this form
>>
> parsing code
>
>> is too twisty.
>>
>
> Yes, I saw that when reading through. I'd like to add more tests and
> simplify the call graph. Does that sound okay?
>
> https://codereview.appspot.com/44040043/
>
Sign in to reply to this message.
mattcottingham_gmail.com
On 27 December 2013 16:47, Brad Fitzpatrick <bradfitz@golang.org> wrote: > I do want to see ...
12 years ago (2013年12月27日 17:44:58 UTC) #7
On 27 December 2013 16:47, Brad Fitzpatrick <bradfitz@golang.org> wrote:
> I do want to see this code simplified, so go for it.
>
I'll start the work in a new CL and mail a work-in-progress in a few days.
> It will have to be simple, readable, documented, and well-tested. And any
> weird behavior is likely frozen at this point, unfortunately.
>
Sure. In that case, probably best to abandon this CL (once I work out how)
and document it in the refactor.
> On Dec 27, 2013 6:45 AM, <MattCottingham@gmail.com> wrote:
>
>> On 2013年12月26日 20:51:11, bradfitz wrote:
>>
>> https://codereview.appspot.com/44040043/diff/40001/src/
>> pkg/net/http/request.go
>>
>>> File src/pkg/net/http/request.go (right):
>>>
>>
>>
>> https://codereview.appspot.com/44040043/diff/40001/src/
>> pkg/net/http/request.go#newcode784
>>
>>> src/pkg/net/http/request.go:784: return err
>>> This looks very intentional.
>>>
>>
>> If this were an acceptable change (and it might be a lot to convince
>>>
>> us all it
>>
>>> is), the proper way to write this would be:
>>>
>>
>> if err != nil {
>>> return err
>>> }
>>>
>>
>> But I'm not convinced this is a safe change.
>>>
>>
>>
>> Agreed. I added a test but it's likely not sufficient by itself.
>>
>> See the TODO comment in parsePostForm which says how all this form
>>>
>> parsing code
>>
>>> is too twisty.
>>>
>>
>> Yes, I saw that when reading through. I'd like to add more tests and
>> simplify the call graph. Does that sound okay?
>>
>> https://codereview.appspot.com/44040043/
>>
>
Sign in to reply to this message.
bradfitz
On Fri, Dec 27, 2013 at 9:44 AM, Matt Cottingham <mattcottingham@gmail.com>wrote: > On 27 December ...
12 years ago (2013年12月27日 17:48:31 UTC) #8
On Fri, Dec 27, 2013 at 9:44 AM, Matt Cottingham
<mattcottingham@gmail.com>wrote:
> On 27 December 2013 16:47, Brad Fitzpatrick <bradfitz@golang.org> wrote:
>
>> I do want to see this code simplified, so go for it.
>>
> I'll start the work in a new CL and mail a work-in-progress in a few days.
>
>> It will have to be simple, readable, documented, and well-tested. And any
>> weird behavior is likely frozen at this point, unfortunately.
>>
> Sure. In that case, probably best to abandon this CL (once I work out how)
> and document it in the refactor.
>
This CL might be acceptable. The method does return an error, and we
already have that error value (even though it was mostly for internal use),
and we don't document what the return value might be. So you might still
be able to make this change, but I'd want to verify that any internal
callers aren't surprised by the change.
The call graph is crazy and I can never remember it. Everything has weird
side effects too.
Sign in to reply to this message.
mattcottingham_gmail.com
On 27 December 2013 17:48, Brad Fitzpatrick <bradfitz@golang.org> wrote: > On Fri, Dec 27, 2013 ...
12 years ago (2013年12月27日 18:13:28 UTC) #9
On 27 December 2013 17:48, Brad Fitzpatrick <bradfitz@golang.org> wrote:
> On Fri, Dec 27, 2013 at 9:44 AM, Matt Cottingham <mattcottingham@gmail.com
> > wrote:
>
>> On 27 December 2013 16:47, Brad Fitzpatrick <bradfitz@golang.org> wrote:
>>
>>> I do want to see this code simplified, so go for it.
>>>
>> I'll start the work in a new CL and mail a work-in-progress in a few days.
>>
>>> It will have to be simple, readable, documented, and well-tested. And
>>> any weird behavior is likely frozen at this point, unfortunately.
>>>
>> Sure. In that case, probably best to abandon this CL (once I work out
>> how) and document it in the refactor.
>>
>
> This CL might be acceptable. The method does return an error, and we
> already have that error value (even though it was mostly for internal use),
> and we don't document what the return value might be. So you might still
> be able to make this change, but I'd want to verify that any internal
> callers aren't surprised by the change.
>
I'll keep this open for now but start the other work from a blank slate.
> The call graph is crazy and I can never remember it. Everything has weird
> side effects too.
>
Well, I have a good excuse to use Go oracle now :)
Sign in to reply to this message.
bradfitz
Did you determine whether this breaks any publicly-visible behavior or side effects?
11 years, 12 months ago (2014年01月14日 23:30:16 UTC) #10
Did you determine whether this breaks any publicly-visible behavior or side
effects?
Sign in to reply to this message.
mattcottingham
On 2014年01月14日 23:30:16, bradfitz wrote: > Did you determine whether this breaks any publicly-visible behavior ...
11 years, 11 months ago (2014年01月16日 22:38:38 UTC) #11
On 2014年01月14日 23:30:16, bradfitz wrote:
> Did you determine whether this breaks any publicly-visible behavior or side
> effects?
Sorry, I've been away for a while, picking things up again now.
I need to take another look and simplify/add more tests to the form handling
before I can be completely sure. Also, as you pointed out the error value might
be better kept for internal use.
Sign in to reply to this message.
rsc
matt, if you'd like this to be in go 1.3 we need to wrap up ...
11 years, 10 months ago (2014年03月05日 20:00:20 UTC) #12
matt, if you'd like this to be in go 1.3 we need to wrap up this review in the
next week or so. or else we can postpone to 1.4.
Sign in to reply to this message.
mattcottingham
Hello golang-codereviews@googlegroups.com, gobot@golang.org, bradfitz@golang.org, rsc@golang.org (cc: golang-codereviews@googlegroups.com), Please take another look.
11 years, 10 months ago (2014年03月09日 20:06:21 UTC) #13
mattcottingham
On 2014年03月09日 20:06:21, mattcottingham wrote: > Hello mailto:golang-codereviews@googlegroups.com, mailto:gobot@golang.org, > mailto:bradfitz@golang.org, mailto:rsc@golang.org (cc: mailto:golang-codereviews@googlegroups.com), > ...
11 years, 10 months ago (2014年03月09日 20:07:29 UTC) #14
On 2014年03月09日 20:06:21, mattcottingham wrote:
> Hello mailto:golang-codereviews@googlegroups.com, mailto:gobot@golang.org,
> mailto:bradfitz@golang.org, mailto:rsc@golang.org (cc:
mailto:golang-codereviews@googlegroups.com),
> 
> Please take another look.
I've made a couple of passes at this and I'm cautiously optimistic it doesn't
break anything. Since this has been open for a while I'll summarise:
- ParseMultipartForm now returns the same error value as MultipartReader when
the content-type is not multipart/form-data, ErrNotMultipart.
- FormValue and PostFormValue call and depend upon side-effects of
ParseMultipartForm. But ParseForm is called before multipartReader (which may
return ErrNotMultipart) so it shouldn't matter.
- FormFile also calls ParseMultipartForm. In this case the return value is
(correctly) used.
- It looks like the `return nil` was a placeholder (see comment on line 706) for
cleaning up parseForm etc.
- The tests added here and in 46750043 should lock in the call graph for a later
refactor.
It might be good to get this in for 1.3, but if we are too close to the cut I'm
happy to postpone too. Let me know what you think.
Sign in to reply to this message.
rsc
thanks. brad?
11 years, 10 months ago (2014年03月13日 02:32:25 UTC) #15
thanks. brad?
Sign in to reply to this message.
bradfitz
LGTM Sorry for the delay. This turned out less scary than it sounded. Thanks for ...
11 years, 9 months ago (2014年04月11日 05:50:00 UTC) #16
LGTM
Sorry for the delay. This turned out less scary than it sounded.
Thanks for the tests.
Sign in to reply to this message.
bradfitz
*** Submitted as https://code.google.com/p/go/source/detail?r=f5ef7ec5b144 *** net/http: Return ErrNotMultipart from ParseMultipartForm if content-type isn't multipart/form-data. Add ...
11 years, 9 months ago (2014年04月11日 05:50:12 UTC) #17
*** Submitted as https://code.google.com/p/go/source/detail?r=f5ef7ec5b144 ***
net/http: Return ErrNotMultipart from ParseMultipartForm if content-type isn't
multipart/form-data.
Add test for multipart form requests with an invalid content-type to ensure
ErrNotMultipart is returned.
Change ParseMultipartForm to return ErrNotMultipart when it is returned by
multipartReader.
Modify test for empty multipart request handling to use POST so that the body is
checked.
Fixes issue 6334.
This is the first changeset working on multipart request handling. Further
changesets
could add more tests and clean up the TODO.
LGTM=bradfitz
R=golang-codereviews, gobot, bradfitz, rsc
CC=golang-codereviews
https://codereview.appspot.com/44040043
Committer: Brad Fitzpatrick <bradfitz@golang.org>
Sign in to reply to this message.
|
This is Rietveld f62528b

AltStyle によって変換されたページ (->オリジナル) /