Closed pongngai closed 4 months ago
Hi. Could you share the Go PDK version that is used? We changed the API definition in later versions of Kong and Go PDK to return byte arrays to fix this issue. Please consider upgrading to the latest version.
Hi,
I have the same issue and the same question
@StarlightIbuki I don't think we're talking about the same module and function.
https://github.com/Kong/go-pdk/blob/master/service/response/response.go#L71
This function returns string
and If the body is binary the function returns an error.
Meanwhile, the request.GetRawBody function actually returns byte[]
So I think this is indeed a bug, as go-pdk doesn't provide any way to manipulate the binary body of the response (e.g. gzip) and returns an error
@psmolkin @pongngai Sorry for replying late. You're right. This is missed in the fix. We planned the fix in 3.7. Will update when the fix is merged.
Internally tracked: KAG-3790
I try to get the response header and body from upstream server by using this code below
The result from logging I can get the header key response but I cannot get the response raw body. This is the error that was printed.
body = err = string field contains invalid UTF-8
I just tried to get the request body by using kong.Request.GetRawBody() as well. It returns an empty byte array but when I try to get the request header everything works fine.
Kong version 3.0.2 Kong config