http_interceptor
http_interceptor copied to clipboard
It is possible to decode all responses to UTF-8 using interceptResponse?
Currently, my interceptResponse looks like:
@override
Future<ResponseData> interceptResponse({required ResponseData data}) async {
if (kDebugMode) {
print("-- RESPONSE --");
print(data.body);
}
RequestExceptionCatcher.checkRequestResponse(
data.statusCode,
);
data.body = utf8.decode(data.bodyBytes);
return data;
}
The problem is that the response body are not changing. Even when i manually set the body value to an empty string, the response.body outside of the intercepter is not changing.
Sorry that it has taken me this long to reply.
In short, I think the library should be able to change it. I will take a look at it as soon as I can and get back on it. Probably in a 2.0.0 release though.
No problem, thanks for the update!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Usually, the encoding used for the body directly corresponds to the encoding tied to the Request you built. [By default it is utf-8, you can check out the behavior of this variable in the docs.
Now, if your server is not sending it using the encoding you set, then it might be an issue with the server and not the client(your flutter/dart app)
Now in other notes, #124 should take care of changing the body, but it is far from a feature implemented. Sorry about that 😞
That's fine. It would be cool to change the body but it's not something that's impossible to address elsewhere in the code.
Your package is awesome :)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.