fix:fix bug in ext-auth wasm plugin (#1152)

This commit is contained in:
韩贤涛
2024-08-05 11:04:31 +08:00
committed by GitHub
parent cc74c0da93
commit 08c64ed467
8 changed files with 275 additions and 122 deletions

View File

@@ -15,6 +15,7 @@
package wrapper
import (
"strconv"
"strings"
"github.com/higress-group/proxy-wasm-go-sdk/proxywasm"
@@ -81,3 +82,16 @@ func IsBinaryResponseBody() bool {
}
return false
}
func HasRequestBody() bool {
contentLengthStr, _ := proxywasm.GetHttpRequestHeader("content-length")
if contentLengthStr != "" {
contentLength, err := strconv.Atoi(contentLengthStr)
if err == nil && contentLength > 0 {
return true
}
}
transferEncodingStr, _ := proxywasm.GetHttpRequestHeader("transfer-encoding")
return strings.Contains(transferEncodingStr, "chunked")
}