mirror of
https://github.com/alibaba/higress.git
synced 2026-06-09 04:37:31 +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
|
conf.redisClient = redisClient
|
||||||
|
|
||||||
ssePathSuffix, ok := v.AsMap()["sse_path_suffix"].(string)
|
ssePathSuffix, ok := v.AsMap()["sse_path_suffix"].(string)
|
||||||
if !ok {
|
if !ok || ssePathSuffix == "" {
|
||||||
return nil, fmt.Errorf("sse path suffix is not set")
|
return nil, fmt.Errorf("sse path suffix is not set or empty")
|
||||||
}
|
}
|
||||||
conf.ssePathSuffix = ssePathSuffix
|
conf.ssePathSuffix = ssePathSuffix
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ type filter struct {
|
|||||||
req *http.Request
|
req *http.Request
|
||||||
serverName string
|
serverName string
|
||||||
message bool
|
message bool
|
||||||
|
proxyURL *url.URL
|
||||||
}
|
}
|
||||||
|
|
||||||
type RequestURL struct {
|
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
|
// Check if request matches any rule in match_list
|
||||||
if !internal.IsMatch(f.config.matchList, url.host, f.path) {
|
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
|
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) {
|
if !strings.HasSuffix(url.parsedURL.Path, f.config.ssePathSuffix) {
|
||||||
|
f.proxyURL = url.parsedURL
|
||||||
return api.Continue
|
return api.Continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,8 +157,8 @@ func (f *filter) EncodeData(buffer api.BufferInstance, endStream bool) api.Statu
|
|||||||
if !endStream {
|
if !endStream {
|
||||||
return api.StopAndBuffer
|
return api.StopAndBuffer
|
||||||
}
|
}
|
||||||
if f.req != nil {
|
if f.proxyURL != nil {
|
||||||
sessionID := f.req.URL.Query().Get("sessionId")
|
sessionID := f.proxyURL.Query().Get("sessionId")
|
||||||
if sessionID != "" {
|
if sessionID != "" {
|
||||||
channel := internal.GetSSEChannelName(sessionID)
|
channel := internal.GetSSEChannelName(sessionID)
|
||||||
publishErr := f.config.redisClient.Publish(channel, buffer.String())
|
publishErr := f.config.redisClient.Publish(channel, buffer.String())
|
||||||
|
|||||||
Reference in New Issue
Block a user