fix: set proxy.http.acceptTypeAllowInt64: true as default (#30720)

issue: #30680

also let the parameter item to be refreshable

Signed-off-by: PowderLi <min.li@zilliz.com>
pull/30372/head
PowderLi 2024-02-29 09:59:07 +08:00 committed by GitHub
parent 3775464b7c
commit 50a78b682e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 11 deletions

View File

@ -91,8 +91,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 := &paramtable.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")

View File

@ -193,15 +193,14 @@ func (s *Server) startHTTPServer(errChan chan error) {
},
})
ginHandler.Use(ginLogger, gin.Recovery())
httpHeaderAllowInt64 := "false"
httpParams := &paramtable.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")

View File

@ -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,

View File

@ -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)
}