Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
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
Łukasz Nowak
caddy
Commits
532ab661
Commit
532ab661
authored
Aug 11, 2016
by
Carter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fully read and close the request body
parent
d56ac28b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
caddyhttp/httpserver/replacer.go
caddyhttp/httpserver/replacer.go
+9
-5
No files found.
caddyhttp/httpserver/replacer.go
View file @
532ab661
...
@@ -163,17 +163,21 @@ func canLogRequest(r *http.Request) (canLog bool) {
...
@@ -163,17 +163,21 @@ func canLogRequest(r *http.Request) (canLog bool) {
// readRequestBody reads the request body and sets a
// readRequestBody reads the request body and sets a
// new io.ReadCloser that has not yet been read.
// new io.ReadCloser that has not yet been read.
func
readRequestBody
(
r
*
http
.
Request
,
n
int64
)
([]
byte
,
error
)
{
func
readRequestBody
(
r
*
http
.
Request
,
n
int64
)
([]
byte
,
error
)
{
defer
r
.
Body
.
Close
()
body
,
err
:=
ioutil
.
ReadAll
(
io
.
LimitReader
(
r
.
Body
,
n
))
body
,
err
:=
ioutil
.
ReadAll
(
io
.
LimitReader
(
r
.
Body
,
n
))
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
mr
:=
io
.
MultiReader
(
// Read the remaining bytes
bytes
.
NewBuffer
(
body
),
remaining
,
err
:=
ioutil
.
ReadAll
(
r
.
Body
)
r
.
Body
,
if
err
!=
nil
{
)
return
nil
,
err
}
r
.
Body
=
ioutil
.
NopCloser
(
mr
)
buf
:=
bytes
.
NewBuffer
(
append
(
body
,
remaining
...
))
r
.
Body
=
ioutil
.
NopCloser
(
buf
)
return
body
,
nil
return
body
,
nil
}
}
...
...
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