flutter_cache_manager icon indicating copy to clipboard operation
flutter_cache_manager copied to clipboard

Http response headers

Open francescopasin opened this issue 5 years ago • 6 comments

🚀 Feature Requests

Currently the CacheManager only returns the body of the http response. It will be really useful to be able to retrieve also the respnse headers.

Contextualize the feature

Some api for example insert the total number of pages (for pagination) in the response header, and currently is impossible to read it.

Describe the feature

The response file could be a json that contains both the headers and the body of the http response.

Platforms affected (mark all that apply)

  • [x] :iphone: iOS
  • [x] :robot: Android

francescopasin avatar Nov 16 '20 12:11 francescopasin

Would you only expect that information when the information is coming right from the source, or also when it is retrieved from the local cache?

renefloor avatar Nov 19 '20 09:11 renefloor

I think it could be useful to cache all the http response (headers, body, status...). I needed this because some api's (like wordpress rest api) insert important pagination info in the headers instead of the body. So when you request a file (either cached or not) the function could return the http.Response objet instead of a File object. This library (https://pub.dev/packages/dio_http_cache), for example, simply allow you to use the "get" request as normal, and handle all the caching in background. The downside is that you are obliged to use the Dio library instead of the "standard" http package. But it's concept of returning the response object is cool, and allows the user to retrieve every information he needs.

francescopasin avatar Nov 19 '20 09:11 francescopasin

That's nice indeed, but I'm not sure if it should be in the scope of this library. Maybe it is better to make a generic http_cache manager that does that.

renefloor avatar Nov 19 '20 09:11 renefloor

Ok, because this library is intended more for files instead of api's right?

francescopasin avatar Nov 19 '20 09:11 francescopasin

Yep

renefloor avatar Nov 19 '20 10:11 renefloor

Ok, well, at the moment I don't have the abilities to create that package so I hope that I gave you the idea for your next package 😁 There is no package that do this except for the one that I linked before. Thanks anyway!

francescopasin avatar Nov 19 '20 10:11 francescopasin