aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/http.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-03-13 19:23:44 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-03-13 19:55:26 +0800
commit555f42cfd836dabe3151becffa63976c91e5344b (patch)
tree92fefaf4d47056a25dc06893fe2257df92f029ab /rpc/http.go
parent6a2d2869f6cb369379eb1c03ed7e55c089e83dd6 (diff)
downloaddexon-555f42cfd836dabe3151becffa63976c91e5344b.tar
dexon-555f42cfd836dabe3151becffa63976c91e5344b.tar.gz
dexon-555f42cfd836dabe3151becffa63976c91e5344b.tar.bz2
dexon-555f42cfd836dabe3151becffa63976c91e5344b.tar.lz
dexon-555f42cfd836dabe3151becffa63976c91e5344b.tar.xz
dexon-555f42cfd836dabe3151becffa63976c91e5344b.tar.zst
dexon-555f42cfd836dabe3151becffa63976c91e5344b.zip
rpc: enforce the 128KB request limits on websockets too
Diffstat (limited to 'rpc/http.go')
-rw-r--r--rpc/http.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/rpc/http.go b/rpc/http.go
index a46d8c2b3..9805d69b6 100644
--- a/rpc/http.go
+++ b/rpc/http.go
@@ -27,16 +27,16 @@ import (
"mime"
"net"
"net/http"
+ "strings"
"sync"
"time"
"github.com/rs/cors"
- "strings"
)
const (
- contentType = "application/json"
- maxHTTPRequestContentLength = 1024 * 128
+ contentType = "application/json"
+ maxRequestContentLength = 1024 * 128
)
var nullAddr, _ = net.ResolveTCPAddr("tcp", "127.0.0.1:0")
@@ -182,8 +182,8 @@ func validateRequest(r *http.Request) (int, error) {
if r.Method == http.MethodPut || r.Method == http.MethodDelete {
return http.StatusMethodNotAllowed, errors.New("method not allowed")
}
- if r.ContentLength > maxHTTPRequestContentLength {
- err := fmt.Errorf("content length too large (%d>%d)", r.ContentLength, maxHTTPRequestContentLength)
+ if r.ContentLength > maxRequestContentLength {
+ err := fmt.Errorf("content length too large (%d>%d)", r.ContentLength, maxRequestContentLength)
return http.StatusRequestEntityTooLarge, err
}
mt, _, err := mime.ParseMediaType(r.Header.Get("content-type"))