From a4219cbb0ff3d62985dafae5a604ed373813cca8 Mon Sep 17 00:00:00 2001 From: PowderLi <135960789+PowderLi@users.noreply.github.com> Date: Thu, 29 Feb 2024 09:59:07 +0800 Subject: [PATCH] fix: [cherry-pick] set proxy.http.acceptTypeAllowInt64: true as default (#30738) issue: #30680 pr: #30720 also let the parameter item to be refreshable Signed-off-by: PowderLi --- .../distributed/proxy/httpserver/handler_v1_test.go | 3 +-- internal/distributed/proxy/service.go | 11 +++++------ pkg/util/paramtable/http_param.go | 4 ++-- pkg/util/paramtable/http_param_test.go | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/internal/distributed/proxy/httpserver/handler_v1_test.go b/internal/distributed/proxy/httpserver/handler_v1_test.go index cfd7c65157..fd6bfd1a8e 100644 --- a/internal/distributed/proxy/httpserver/handler_v1_test.go +++ b/internal/distributed/proxy/httpserver/handler_v1_test.go @@ -87,8 +87,7 @@ func initHTTPServer(proxy types.ProxyComponent, needAuth bool) *gin.Engine { ginHandler.Use(func(c *gin.Context) { _, err := strconv.ParseBool(c.Request.Header.Get(HTTPHeaderAllowInt64)) if err != nil { - httpParams := ¶mtable.Get().HTTPCfg - if httpParams.AcceptTypeAllowInt64.GetAsBool() { + if paramtable.Get().HTTPCfg.AcceptTypeAllowInt64.GetAsBool() { c.Request.Header.Set(HTTPHeaderAllowInt64, "true") } else { c.Request.Header.Set(HTTPHeaderAllowInt64, "false") diff --git a/internal/distributed/proxy/service.go b/internal/distributed/proxy/service.go index a5ca2512d8..630e210bcb 100644 --- a/internal/distributed/proxy/service.go +++ b/internal/distributed/proxy/service.go @@ -174,15 +174,14 @@ func (s *Server) startHTTPServer(errChan chan error) { SkipPaths: proxy.Params.ProxyCfg.GinLogSkipPaths.GetAsStrings(), }) ginHandler.Use(ginLogger, gin.Recovery()) - httpHeaderAllowInt64 := "false" - httpParams := ¶mtable.Get().HTTPCfg - if httpParams.AcceptTypeAllowInt64.GetAsBool() { - httpHeaderAllowInt64 = "true" - } ginHandler.Use(func(c *gin.Context) { _, err := strconv.ParseBool(c.Request.Header.Get(httpserver.HTTPHeaderAllowInt64)) if err != nil { - c.Request.Header.Set(httpserver.HTTPHeaderAllowInt64, httpHeaderAllowInt64) + if paramtable.Get().HTTPCfg.AcceptTypeAllowInt64.GetAsBool() { + c.Request.Header.Set(httpserver.HTTPHeaderAllowInt64, "true") + } else { + c.Request.Header.Set(httpserver.HTTPHeaderAllowInt64, "false") + } } c.Writer.Header().Set("Access-Control-Allow-Origin", "*") c.Writer.Header().Set("Access-Control-Allow-Credentials", "true") diff --git a/pkg/util/paramtable/http_param.go b/pkg/util/paramtable/http_param.go index fabab9a1fe..118babea3e 100644 --- a/pkg/util/paramtable/http_param.go +++ b/pkg/util/paramtable/http_param.go @@ -4,7 +4,7 @@ type httpConfig struct { Enabled ParamItem `refreshable:"false"` DebugMode ParamItem `refreshable:"false"` Port ParamItem `refreshable:"false"` - AcceptTypeAllowInt64 ParamItem `refreshable:"false"` + AcceptTypeAllowInt64 ParamItem `refreshable:"true"` EnablePprof ParamItem `refreshable:"false"` RequestTimeoutMs ParamItem `refreshable:"false"` } @@ -39,7 +39,7 @@ func (p *httpConfig) init(base *BaseTable) { p.AcceptTypeAllowInt64 = ParamItem{ Key: "proxy.http.acceptTypeAllowInt64", - DefaultValue: "false", + DefaultValue: "true", Version: "2.3.2", Doc: "high-level restful api, whether http client can deal with int64", PanicIfEmpty: false, diff --git a/pkg/util/paramtable/http_param_test.go b/pkg/util/paramtable/http_param_test.go index d696d0c63a..5d1748f499 100644 --- a/pkg/util/paramtable/http_param_test.go +++ b/pkg/util/paramtable/http_param_test.go @@ -13,6 +13,6 @@ func TestHTTPConfig_Init(t *testing.T) { assert.Equal(t, cfg.Enabled.GetAsBool(), true) assert.Equal(t, cfg.DebugMode.GetAsBool(), false) assert.Equal(t, cfg.Port.GetValue(), "") - assert.Equal(t, cfg.AcceptTypeAllowInt64.GetValue(), "false") + assert.Equal(t, cfg.AcceptTypeAllowInt64.GetValue(), "true") assert.Equal(t, cfg.EnablePprof.GetAsBool(), true) }