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

`requestTimeout` used to be a setter but not anymore with latest version

aytunch opened this issue · comments

I am upgrading to the latest packages:

  # http_interceptor: ^1.0.2
  http_interceptor: ^2.0.0-beta.8

I did most of the migrations but in the old code the requestTimeout of InterceptedClient was being set on certain situations. New API does not allow this. How can I migrate?

As a temporary workaround, I am copying my current client and changing the requestTimeout. After response is fetched, I close the copied client. Is this OK?

    final copiedClient = InterceptedClient.build(
      interceptors: _client.interceptors,
      retryPolicy: _client.retryPolicy,
      requestTimeout: requestTimeoutInSeconds == null
          ? defaultRequestTimeout
          : Duration(seconds: requestTimeoutInSeconds),
    );
   
    responseFuture = copiedClient.get(
          uri,
          headers: headers,
        );

    final response = await responseFuture;
    // close the copied client which we used for overriding the timeout value.
    copiedClient.close();


This is modification not made on purpose, I'll roll that change back so that the previous behavior is still allowed.

#147 takes care of it and it should be available on 2.0.0