mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-04 14:08:39 +00:00
node, cmd/clef, graphql: disable gzip on engine API (#35057)
Add a disableGzip parameter to NewHTTPHandlerStack and httpConfig. initAuth sets it true so compression is disabled in the engine api. Public HTTP RPC behavior is unchanged.
This commit is contained in:
parent
ab20d50dba
commit
b0df33967c
4 changed files with 9 additions and 4 deletions
|
|
@ -739,7 +739,7 @@ func signer(c *cli.Context) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Could not register API: %w", err)
|
utils.Fatalf("Could not register API: %w", err)
|
||||||
}
|
}
|
||||||
handler := node.NewHTTPHandlerStack(srv, cors, vhosts, nil)
|
handler := node.NewHTTPHandlerStack(srv, cors, vhosts, nil, false)
|
||||||
|
|
||||||
// set port
|
// set port
|
||||||
port := c.Int(rpcPortFlag.Name)
|
port := c.Int(rpcPortFlag.Name)
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ func newHandler(stack *node.Node, backend ethapi.Backend, filterSystem *filters.
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
h := handler{Schema: s}
|
h := handler{Schema: s}
|
||||||
handler := node.NewHTTPHandlerStack(h, cors, vhosts, nil)
|
handler := node.NewHTTPHandlerStack(h, cors, vhosts, nil, false)
|
||||||
|
|
||||||
stack.RegisterHandler("GraphQL UI", "/graphql/ui", GraphiQL{})
|
stack.RegisterHandler("GraphQL UI", "/graphql/ui", GraphiQL{})
|
||||||
stack.RegisterHandler("GraphQL UI", "/graphql/ui/", GraphiQL{})
|
stack.RegisterHandler("GraphQL UI", "/graphql/ui/", GraphiQL{})
|
||||||
|
|
|
||||||
|
|
@ -445,6 +445,7 @@ func (n *Node) startRPC() error {
|
||||||
Vhosts: n.config.AuthVirtualHosts,
|
Vhosts: n.config.AuthVirtualHosts,
|
||||||
Modules: DefaultAuthModules,
|
Modules: DefaultAuthModules,
|
||||||
prefix: DefaultAuthPrefix,
|
prefix: DefaultAuthPrefix,
|
||||||
|
disableGzip: true,
|
||||||
rpcEndpointConfig: sharedConfig,
|
rpcEndpointConfig: sharedConfig,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ type httpConfig struct {
|
||||||
CorsAllowedOrigins []string
|
CorsAllowedOrigins []string
|
||||||
Vhosts []string
|
Vhosts []string
|
||||||
prefix string // path prefix on which to mount http handler
|
prefix string // path prefix on which to mount http handler
|
||||||
|
disableGzip bool
|
||||||
rpcEndpointConfig
|
rpcEndpointConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -320,7 +321,7 @@ func (h *httpServer) enableRPC(apis []rpc.API, config httpConfig) error {
|
||||||
}
|
}
|
||||||
h.httpConfig = config
|
h.httpConfig = config
|
||||||
h.httpHandler.Store(&rpcHandler{
|
h.httpHandler.Store(&rpcHandler{
|
||||||
Handler: NewHTTPHandlerStack(srv, config.CorsAllowedOrigins, config.Vhosts, config.jwtSecret),
|
Handler: NewHTTPHandlerStack(srv, config.CorsAllowedOrigins, config.Vhosts, config.jwtSecret, config.disableGzip),
|
||||||
prefix: config.prefix,
|
prefix: config.prefix,
|
||||||
server: srv,
|
server: srv,
|
||||||
})
|
})
|
||||||
|
|
@ -402,13 +403,16 @@ func isWebsocket(r *http.Request) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewHTTPHandlerStack returns wrapped http-related handlers
|
// NewHTTPHandlerStack returns wrapped http-related handlers
|
||||||
func NewHTTPHandlerStack(srv http.Handler, cors []string, vhosts []string, jwtSecret []byte) http.Handler {
|
func NewHTTPHandlerStack(srv http.Handler, cors []string, vhosts []string, jwtSecret []byte, disableGzip bool) http.Handler {
|
||||||
// Wrap the CORS-handler within a host-handler
|
// Wrap the CORS-handler within a host-handler
|
||||||
handler := newCorsHandler(srv, cors)
|
handler := newCorsHandler(srv, cors)
|
||||||
handler = newVHostHandler(vhosts, handler)
|
handler = newVHostHandler(vhosts, handler)
|
||||||
if len(jwtSecret) != 0 {
|
if len(jwtSecret) != 0 {
|
||||||
handler = newJWTHandler(jwtSecret, handler)
|
handler = newJWTHandler(jwtSecret, handler)
|
||||||
}
|
}
|
||||||
|
if disableGzip {
|
||||||
|
return handler
|
||||||
|
}
|
||||||
return newGzipHandler(handler)
|
return newGzipHandler(handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue