mirror of
https://github.com/alibaba/higress.git
synced 2026-03-08 10:40:48 +08:00
fix: fix bug of mcp server proxy (#1981)
This commit is contained in:
@@ -88,8 +88,8 @@ func (p *parser) Parse(any *anypb.Any, callbacks api.ConfigCallbackHandler) (int
|
||||
conf.redisClient = redisClient
|
||||
|
||||
ssePathSuffix, ok := v.AsMap()["sse_path_suffix"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("sse path suffix is not set")
|
||||
if !ok || ssePathSuffix == "" {
|
||||
return nil, fmt.Errorf("sse path suffix is not set or empty")
|
||||
}
|
||||
conf.ssePathSuffix = ssePathSuffix
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ type filter struct {
|
||||
req *http.Request
|
||||
serverName string
|
||||
message bool
|
||||
proxyURL *url.URL
|
||||
}
|
||||
|
||||
type RequestURL struct {
|
||||
@@ -54,6 +55,7 @@ func (f *filter) DecodeHeaders(header api.RequestHeaderMap, endStream bool) api.
|
||||
|
||||
// Check if request matches any rule in match_list
|
||||
if !internal.IsMatch(f.config.matchList, url.host, f.path) {
|
||||
api.LogDebugf("Request does not match any rule in match_list: %s", url.parsedURL.String())
|
||||
return api.Continue
|
||||
}
|
||||
|
||||
@@ -94,6 +96,7 @@ func (f *filter) DecodeHeaders(header api.RequestHeaderMap, endStream bool) api.
|
||||
}
|
||||
}
|
||||
if !strings.HasSuffix(url.parsedURL.Path, f.config.ssePathSuffix) {
|
||||
f.proxyURL = url.parsedURL
|
||||
return api.Continue
|
||||
}
|
||||
|
||||
@@ -154,8 +157,8 @@ func (f *filter) EncodeData(buffer api.BufferInstance, endStream bool) api.Statu
|
||||
if !endStream {
|
||||
return api.StopAndBuffer
|
||||
}
|
||||
if f.req != nil {
|
||||
sessionID := f.req.URL.Query().Get("sessionId")
|
||||
if f.proxyURL != nil {
|
||||
sessionID := f.proxyURL.Query().Get("sessionId")
|
||||
if sessionID != "" {
|
||||
channel := internal.GetSSEChannelName(sessionID)
|
||||
publishErr := f.config.redisClient.Publish(channel, buffer.String())
|
||||
|
||||
Reference in New Issue
Block a user