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
87f5b412
Unverified
Commit
87f5b412
authored
Nov 16, 2017
by
Péter Szilágyi
Committed by
GitHub
Nov 16, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15496 from karalabe/rpc-get-healthcheck
rpc: allow dumb empty requests for AWS health checks
parents
5aa3eac2
4013e233
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
http.go
rpc/http.go
+10
-7
No files found.
rpc/http.go
View file @
87f5b412
...
...
@@ -146,13 +146,17 @@ func NewHTTPServer(cors []string, srv *Server) *http.Server {
// ServeHTTP serves JSON-RPC requests over HTTP.
func
(
srv
*
Server
)
ServeHTTP
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
// Permit dumb empty requests for remote health-checks (AWS)
if
r
.
Method
==
"GET"
&&
r
.
ContentLength
==
0
&&
r
.
URL
.
RawQuery
==
""
{
return
}
// For meaningful requests, validate it's size and content type
if
r
.
ContentLength
>
maxHTTPRequestContentLength
{
http
.
Error
(
w
,
fmt
.
Sprintf
(
"content length too large (%d>%d)"
,
r
.
ContentLength
,
maxHTTPRequestContentLength
),
http
.
StatusRequestEntityTooLarge
)
return
}
ct
:=
r
.
Header
.
Get
(
"content-type"
)
mt
,
_
,
err
:=
mime
.
ParseMediaType
(
ct
)
if
err
!=
nil
||
mt
!=
"application/json"
{
...
...
@@ -161,14 +165,13 @@ func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http
.
StatusUnsupportedMediaType
)
return
}
w
.
Header
()
.
Set
(
"content-type"
,
"application/json"
)
// create a codec that reads direct from the request body until
// EOF and writes the response to w and order the server to process
// a single request.
// All checks passed, create a codec that reads direct from the request body
// untilEOF and writes the response to w and order the server to process a
// single request.
codec
:=
NewJSONCodec
(
&
httpReadWriteNopCloser
{
r
.
Body
,
w
})
defer
codec
.
Close
()
w
.
Header
()
.
Set
(
"content-type"
,
"application/json"
)
srv
.
ServeSingleRequest
(
codec
,
OptionMethodInvocation
)
}
...
...
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