mirror of
https://github.com/alibaba/higress.git
synced 2026-05-24 12:47:27 +08:00
waf skip body when protocol is grpc, websocket or sse (#943)
This commit is contained in:
@@ -138,3 +138,34 @@ func logError(error ctypes.MatchedRule) {
|
||||
proxywasm.LogDebug(msg)
|
||||
}
|
||||
}
|
||||
|
||||
func isWebSocketRequest() bool {
|
||||
if value, err := proxywasm.GetHttpRequestHeader("Upgrade"); err == nil {
|
||||
if value == "websocket" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isSSERequest() bool {
|
||||
if value, err := proxywasm.GetHttpRequestHeader("Accept"); err == nil {
|
||||
if value == "text/event-stream" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isGrpcRequest() bool {
|
||||
if value, err := proxywasm.GetHttpRequestHeader("Content-Type"); err == nil {
|
||||
if value == "application/grpc" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func ignoreBody() bool {
|
||||
return isWebSocketRequest() || isSSERequest() || isGrpcRequest()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user