hurshi / dio-http-cache

http cache lib for Flutter dio like RxCache
Apache License 2.0
274 stars 223 forks source link

Preserve response headers #18

Closed JordanMarshall closed 4 years ago

JordanMarshall commented 4 years ago

It seems that the headers of network responses are discarded, and when a response is built from the cache it uses the request headers instead.

In my use case the response headers for a certain request contain crucial link information for paginated data. For example, I make a request to an API that returns 100 items in the first 'page', and the headers contain a link to the next 'page' that also returns 100 items and also has link headers for the subsequent page, and so forth. However, if the response is a cached response then these headers will be missing, which means that I cannot access more than a single page of data even if the subsequent pages have been previously cached.

Preserving the original headers and restoring them in the cached response would solve this issue.

hurshi commented 4 years ago

Hello, thanks for your feedback. It has fixed in new version: 0.2.5

JordanMarshall commented 4 years ago

Thanks for the quick update. I have tested the new version and it appears to be working as expected.