CodingAleCR / http_interceptor

A lightweight, simple plugin that allows you to intercept request and response objects and modify them if desired.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Greismorr opened this issue · 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.

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!

commented

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.