mirror of
https://github.com/alibaba/higress.git
synced 2026-05-23 04:07:26 +08:00
fix ai proxy check request body logic (#1252)
This commit is contained in:
@@ -84,14 +84,19 @@ func IsBinaryResponseBody() bool {
|
||||
}
|
||||
|
||||
func HasRequestBody() bool {
|
||||
contentTypeStr, _ := proxywasm.GetHttpRequestHeader("content-type")
|
||||
contentLengthStr, _ := proxywasm.GetHttpRequestHeader("content-length")
|
||||
transferEncodingStr, _ := proxywasm.GetHttpRequestHeader("transfer-encoding")
|
||||
proxywasm.LogDebugf("check has request body: contentType:%s, contentLengthStr:%s, transferEncodingStr:%s",
|
||||
contentTypeStr, contentLengthStr, transferEncodingStr)
|
||||
if contentTypeStr != "" {
|
||||
return true
|
||||
}
|
||||
if contentLengthStr != "" {
|
||||
contentLength, err := strconv.Atoi(contentLengthStr)
|
||||
if err == nil && contentLength > 0 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
transferEncodingStr, _ := proxywasm.GetHttpRequestHeader("transfer-encoding")
|
||||
return strings.Contains(transferEncodingStr, "chunked")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user