Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
4fe30bf5
Commit
4fe30bf5
authored
Nov 09, 2017
by
bas-vk
Committed by
Felix Lange
Nov 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rpc: check content-type for HTTP requests (#15220)
parent
4732ee89
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
http.go
rpc/http.go
+11
-0
No files found.
rpc/http.go
View file @
4fe30bf5
...
...
@@ -23,6 +23,7 @@ import (
"fmt"
"io"
"io/ioutil"
"mime"
"net"
"net/http"
"sync"
...
...
@@ -151,6 +152,16 @@ func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http
.
StatusRequestEntityTooLarge
)
return
}
ct
:=
r
.
Header
.
Get
(
"content-type"
)
mt
,
_
,
err
:=
mime
.
ParseMediaType
(
ct
)
if
err
!=
nil
||
mt
!=
"application/json"
{
http
.
Error
(
w
,
"invalid content type, only application/json is supported"
,
http
.
StatusUnsupportedMediaType
)
return
}
w
.
Header
()
.
Set
(
"content-type"
,
"application/json"
)
// create a codec that reads direct from the request body until
...
...
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