fix: Skip reading non-JSON request bodies in ai-proxy (#1914)

This commit is contained in:
Kent Dong
2025-03-18 21:23:54 +08:00
committed by GitHub
parent 029c3e75fc
commit eef8adf42f

View File

@@ -91,6 +91,11 @@ func onHttpRequestHeader(ctx wrapper.HttpContext, pluginConfig config.PluginConf
}
}
if contentType, _ := proxywasm.GetHttpRequestHeader(util.HeaderContentType); contentType != "" && !strings.Contains(contentType, util.MimeTypeApplicationJson) {
ctx.DontReadRequestBody()
log.Debugf("[onHttpRequestHeader] unsupported content type: %s, will not process the request body", contentType)
}
if apiName == "" {
ctx.DontReadRequestBody()
ctx.DontReadResponseBody()