I am performing Head call as below using http:
Future<void> fetchModifiedDate(String fileUrl,BuildContext context) async{
if (await checkNetworkConnection(context)) {
var responseValue = [];
var response = http.head(Uri.parse(fileUrl));
response.then((value) {
responseValue = value.headers.values.toString().split(",");
modifiedDate = responseValue[1].trim();
print(value.headers.toString());
print(value.headers.values.toString());
});
}
The values which I am getting from Header is as below :
- For print(value.hedaers.toString()),
{x-served-by: psm100.akshar-dev.ml, connection: keep-alive, last-modified: Thu, 13 Oct 2022 00:09:35 GMT, accept-ranges: bytes, date: Wed, 02 Nov 2022 10:24:35 GMT, content-length: 69910, etag: "6347573f-11116", content-type: application/json, server: openresty}
- For print(value.headers.values.toString()),
(psm100.akshar-dev.ml, keep-alive, Thu, 13 Oct 2022 00:09:35 GMT, …, application/json, openresty)
I want specific header value i.e. The value for last-modified key.
How can I get it?
>Solution :
Try the following code
value.hedaers['last-modified']