http_interceptor icon indicating copy to clipboard operation
http_interceptor copied to clipboard

It is possible to decode all responses to UTF-8 using interceptResponse?

Open Greismorr opened this issue 2 years ago • 7 comments

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.

Greismorr avatar Dec 15 '22 17:12 Greismorr

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.

CodingAleCR avatar Jan 31 '23 15:01 CodingAleCR

No problem, thanks for the update!

Greismorr avatar Feb 01 '23 01:02 Greismorr

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.

stale[bot] avatar Apr 02 '23 06:04 stale[bot]

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)

CodingAleCR avatar Jun 06 '23 18:06 CodingAleCR

Now in other notes, #124 should take care of changing the body, but it is far from a feature implemented. Sorry about that 😞

CodingAleCR avatar Jun 06 '23 18:06 CodingAleCR

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 :)

Greismorr avatar Jun 17 '23 01:06 Greismorr

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.

stale[bot] avatar Sep 17 '23 00:09 stale[bot]