Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
2aa50c24
Commit
2aa50c24
authored
Dec 16, 2015
by
astaxie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1486 from KilledKenny/oomDos
Added MaxMemory limit to CopyBody() Supersedes #1484
parents
dbc4ac69
52c4c1fb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
input.go
context/input.go
+4
-2
router.go
router.go
+1
-1
No files found.
context/input.go
View file @
2aa50c24
...
...
@@ -17,6 +17,7 @@ package context
import
(
"bytes"
"errors"
"io"
"io/ioutil"
"net/url"
"reflect"
...
...
@@ -313,8 +314,9 @@ func (input *BeegoInput) Session(key interface{}) interface{} {
}
// CopyBody returns the raw request body data as bytes.
func
(
input
*
BeegoInput
)
CopyBody
()
[]
byte
{
requestbody
,
_
:=
ioutil
.
ReadAll
(
input
.
Context
.
Request
.
Body
)
func
(
input
*
BeegoInput
)
CopyBody
(
MaxMemory
int64
)
[]
byte
{
safe
:=
&
io
.
LimitedReader
{
R
:
input
.
Context
.
Request
.
Body
,
N
:
MaxMemory
}
requestbody
,
_
:=
ioutil
.
ReadAll
(
safe
)
input
.
Context
.
Request
.
Body
.
Close
()
bf
:=
bytes
.
NewBuffer
(
requestbody
)
input
.
Context
.
Request
.
Body
=
ioutil
.
NopCloser
(
bf
)
...
...
router.go
View file @
2aa50c24
...
...
@@ -653,7 +653,7 @@ func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request)
if
r
.
Method
!=
"GET"
&&
r
.
Method
!=
"HEAD"
{
if
BConfig
.
CopyRequestBody
&&
!
context
.
Input
.
IsUpload
()
{
context
.
Input
.
CopyBody
()
context
.
Input
.
CopyBody
(
BConfig
.
MaxMemory
)
}
context
.
Input
.
ParseFormOrMulitForm
(
BConfig
.
MaxMemory
)
}
...
...
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