Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
db16bca1
Commit
db16bca1
authored
May 01, 2011
by
Brad Fitzpatrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
multipart: return an error on Reader EOF, not (nil, nil)
R=rsc, adg CC=golang-dev
https://golang.org/cl/4430074
parent
366986a3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
14 deletions
+11
-14
src/pkg/mime/multipart/formdata.go
src/pkg/mime/multipart/formdata.go
+3
-3
src/pkg/mime/multipart/multipart.go
src/pkg/mime/multipart/multipart.go
+4
-7
src/pkg/mime/multipart/multipart_test.go
src/pkg/mime/multipart/multipart_test.go
+4
-4
No files found.
src/pkg/mime/multipart/formdata.go
View file @
db16bca1
...
...
@@ -30,12 +30,12 @@ func (r *multiReader) ReadForm(maxMemory int64) (f *Form, err os.Error) {
maxValueBytes
:=
int64
(
10
<<
20
)
// 10 MB is a lot of text.
for
{
p
,
err
:=
r
.
NextPart
()
if
err
==
os
.
EOF
{
break
}
if
err
!=
nil
{
return
nil
,
err
}
if
p
==
nil
{
break
}
name
:=
p
.
FormName
()
if
name
==
""
{
...
...
src/pkg/mime/multipart/multipart.go
View file @
db16bca1
...
...
@@ -30,10 +30,8 @@ var headerRegexp *regexp.Regexp = regexp.MustCompile("^([a-zA-Z0-9\\-]+): *([^\r
// Reader's underlying parser consumes its input as needed. Seeking
// isn't supported.
type
Reader
interface
{
// NextPart returns the next part in the multipart, or (nil,
// nil) on EOF. An error is returned if the underlying reader
// reports errors, or on truncated or otherwise malformed
// input.
// NextPart returns the next part in the multipart or an error.
// When there are no more parts, the error os.EOF is returned.
NextPart
()
(
*
Part
,
os
.
Error
)
// ReadForm parses an entire multipart message whose parts have
...
...
@@ -207,9 +205,8 @@ func (mr *multiReader) NextPart() (*Part, os.Error) {
}
if
hasPrefixThenNewline
(
line
,
mr
.
dashBoundaryDash
)
{
// Expected EOF (no error)
// TODO(bradfitz): should return an os.EOF error here, not using nil for errors
return
nil
,
nil
// Expected EOF
return
nil
,
os
.
EOF
}
if
expectNewPart
{
...
...
src/pkg/mime/multipart/multipart_test.go
View file @
db16bca1
...
...
@@ -201,8 +201,8 @@ func testMultipart(t *testing.T, r io.Reader) {
if
part
!=
nil
{
t
.
Error
(
"Didn't expect a fifth part."
)
}
if
err
!=
nil
{
t
.
Errorf
(
"
Unexpected error getting fifth part:
%v"
,
err
)
if
err
!=
os
.
EOF
{
t
.
Errorf
(
"
On fifth part expected os.EOF; got
%v"
,
err
)
}
}
...
...
@@ -246,8 +246,8 @@ func TestVariousTextLineEndings(t *testing.T) {
if
part
!=
nil
{
t
.
Errorf
(
"Unexpected part in test %d"
,
testNum
)
}
if
err
!=
nil
{
t
.
Errorf
(
"
Unexpected error in test %d:
%v"
,
testNum
,
err
)
if
err
!=
os
.
EOF
{
t
.
Errorf
(
"
On test %d expected os.EOF; got
%v"
,
testNum
,
err
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment