diff --git a/go.mod b/go.mod index fb7ae5816..66b9c2a51 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/Shopify/sarama v1.19.0 github.com/alibaba/sentinel-golang v1.0.4 github.com/apache/dubbo-getty v1.4.8 - github.com/apache/dubbo-go-hessian2 v1.11.0 + github.com/apache/dubbo-go-hessian2 v1.11.1 github.com/cch123/supermonkey v1.0.1 github.com/creasty/defaults v1.5.2 github.com/dubbo-go-pixiu/pixiu-api v0.1.6-0.20220427143451-c0a68bf5b29a diff --git a/go.sum b/go.sum index 3183c857e..6744b7ad7 100644 --- a/go.sum +++ b/go.sum @@ -80,6 +80,8 @@ github.com/apache/dubbo-go-hessian2 v1.9.1/go.mod h1:xQUjE7F8PX49nm80kChFvepA/Av github.com/apache/dubbo-go-hessian2 v1.9.3/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= github.com/apache/dubbo-go-hessian2 v1.11.0 h1:VTdT6NStuEqNmyT3AdSN2DLDBqhXvAAyAAAoh9hLavk= github.com/apache/dubbo-go-hessian2 v1.11.0/go.mod h1:7rEw9guWABQa6Aqb8HeZcsYPHsOS7XT1qtJvkmI6c5w= +github.com/apache/dubbo-go-hessian2 v1.11.1-0.20220704061226-83d6845c8183 h1:lqz0mmcsg1oMJnSjMyfDoMt6cs7yXTCRUqgmgNHVJNo= +github.com/apache/dubbo-go-hessian2 v1.11.1-0.20220704061226-83d6845c8183/go.mod h1:7rEw9guWABQa6Aqb8HeZcsYPHsOS7XT1qtJvkmI6c5w= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= diff --git a/pkg/common/constant/http.go b/pkg/common/constant/http.go index 3d248e61d..9a58f8133 100644 --- a/pkg/common/constant/http.go +++ b/pkg/common/constant/http.go @@ -53,8 +53,9 @@ const ( ) const ( - DubboHttpDubboVersion = "x-dubbo-http1.1-dubbo-version" - DubboServiceProtocol = "x-dubbo-service-protocol" - DubboServiceVersion = "x-dubbo-service-version" - DubboGroup = "x-dubbo-service-group" + DubboHttpDubboVersion = "x-dubbo-http1.1-dubbo-version" + DubboServiceProtocol = "x-dubbo-service-protocol" + DubboServiceVersion = "x-dubbo-service-version" + DubboGroup = "x-dubbo-service-group" + DubboServiceMethodTypes = "x-dubbo-service-method-overloading" ) diff --git a/pkg/filter/http/dubboproxy/dubbo.go b/pkg/filter/http/dubboproxy/dubbo.go index e358d24c9..694c9ab59 100644 --- a/pkg/filter/http/dubboproxy/dubbo.go +++ b/pkg/filter/http/dubboproxy/dubbo.go @@ -134,13 +134,8 @@ func (f *Filter) Decode(hc *pixiuHttp.HttpContext) filter.FilterStatus { interfaceKey := service groupKey := hc.Request.Header.Get(constant.DubboGroup) - if groupKey == "" { - groupKey = "default" - } versionKey := hc.Request.Header.Get(constant.DubboServiceVersion) - if versionKey == "" { - versionKey = "1.0.0" - } + types := hc.Request.Header.Get(constant.DubboServiceMethodTypes) rawBody, err := ioutil.ReadAll(hc.Request.Body) if err != nil { @@ -150,8 +145,8 @@ func (f *Filter) Decode(hc *pixiuHttp.HttpContext) filter.FilterStatus { return filter.Stop } - mapBody := map[string]interface{}{} - if err := json.Unmarshal(rawBody, &mapBody); err != nil { + var body interface{} + if err := json.Unmarshal(rawBody, &body); err != nil { logger.Infof("[dubbo-go-pixiu] unmarshal request body error %v", err) bt, _ := json.Marshal(pixiuHttp.ErrResponse{Message: fmt.Sprintf("unmarshal request body error %v", err)}) hc.SendLocalReply(http.StatusBadRequest, bt) @@ -167,14 +162,11 @@ func (f *Filter) Decode(hc *pixiuHttp.HttpContext) filter.FilterStatus { valuesList []hessian.Object ) - types := mapBody["types"] - if typesString, ok := types.(string); ok { - typesList = strings.Split(typesString, ",") - } else if _, ok = types.([]string); ok { - typesList = types.([]string) + if types != "" { + typesList = strings.Split(types, ",") } - values := mapBody["values"] + values := body if _, ok := values.([]interface{}); ok { for _, v := range values.([]interface{}) { valuesList = append(valuesList, v)