mirror of
https://github.com/alibaba/higress.git
synced 2026-06-09 20:57:32 +08:00
compatiable for SAA
This commit is contained in:
@@ -3,6 +3,7 @@ package mcp_server
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/alibaba/higress/plugins/golang-filter/mcp-session/common"
|
"github.com/alibaba/higress/plugins/golang-filter/mcp-session/common"
|
||||||
"github.com/envoyproxy/envoy/contrib/golang/common/go/api"
|
"github.com/envoyproxy/envoy/contrib/golang/common/go/api"
|
||||||
@@ -17,6 +18,7 @@ type filter struct {
|
|||||||
req *http.Request
|
req *http.Request
|
||||||
message bool
|
message bool
|
||||||
path string
|
path string
|
||||||
|
host string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *filter) DecodeHeaders(header api.RequestHeaderMap, endStream bool) api.StatusType {
|
func (f *filter) DecodeHeaders(header api.RequestHeaderMap, endStream bool) api.StatusType {
|
||||||
@@ -25,9 +27,10 @@ func (f *filter) DecodeHeaders(header api.RequestHeaderMap, endStream bool) api.
|
|||||||
return api.Continue
|
return api.Continue
|
||||||
}
|
}
|
||||||
f.path = url.ParsedURL.Path
|
f.path = url.ParsedURL.Path
|
||||||
|
f.host = url.Host
|
||||||
|
|
||||||
for _, server := range f.config.servers {
|
for _, server := range f.config.servers {
|
||||||
if common.MatchDomainList(url.ParsedURL.Host, server.DomainList) && url.ParsedURL.Path == server.BaseServer.GetMessageEndpoint() {
|
if common.MatchDomainList(f.host, server.DomainList) && strings.HasPrefix(f.path, server.BaseServer.GetMessageEndpoint()) {
|
||||||
if url.Method != http.MethodPost {
|
if url.Method != http.MethodPost {
|
||||||
f.callbacks.DecoderFilterCallbacks().SendLocalReply(http.StatusMethodNotAllowed, "Method not allowed", nil, 0, "")
|
f.callbacks.DecoderFilterCallbacks().SendLocalReply(http.StatusMethodNotAllowed, "Method not allowed", nil, 0, "")
|
||||||
return api.LocalReply
|
return api.LocalReply
|
||||||
@@ -59,7 +62,7 @@ func (f *filter) DecodeHeaders(header api.RequestHeaderMap, endStream bool) api.
|
|||||||
func (f *filter) DecodeData(buffer api.BufferInstance, endStream bool) api.StatusType {
|
func (f *filter) DecodeData(buffer api.BufferInstance, endStream bool) api.StatusType {
|
||||||
if f.message {
|
if f.message {
|
||||||
for _, server := range f.config.servers {
|
for _, server := range f.config.servers {
|
||||||
if f.path == server.BaseServer.GetMessageEndpoint() {
|
if common.MatchDomainList(f.host, server.DomainList) && strings.HasPrefix(f.path, server.BaseServer.GetMessageEndpoint()) {
|
||||||
if !endStream {
|
if !endStream {
|
||||||
return api.StopAndBuffer
|
return api.StopAndBuffer
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user