mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 05:36:46 +00:00
rpc: use slices.Contains
Signed-off-by: deepdring <deepdrink@icloud.com>
This commit is contained in:
parent
2dbb580f51
commit
b8c237aea8
1 changed files with 3 additions and 4 deletions
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"mime"
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -351,10 +352,8 @@ func (s *Server) validateRequest(r *http.Request) (int, error) {
|
||||||
}
|
}
|
||||||
// Check content-type
|
// Check content-type
|
||||||
if mt, _, err := mime.ParseMediaType(r.Header.Get("content-type")); err == nil {
|
if mt, _, err := mime.ParseMediaType(r.Header.Get("content-type")); err == nil {
|
||||||
for _, accepted := range acceptedContentTypes {
|
if slices.Contains(acceptedContentTypes, mt) {
|
||||||
if accepted == mt {
|
return 0, nil
|
||||||
return 0, nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Invalid content-type
|
// Invalid content-type
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue