'Why flutter http response in web missing headers?
Solution 1:[1]
I have the following:
Response headers web:
"Origin":"http://localhost:57986"
Example code:
Future<File> downloadFile(String url, String pathFile) async {
File file = new File(pathFile);
var request = await http.post(Uri.parse(url), encoding: Encoding.getByName('utf8'), headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "POST, GET, OPTIONS, PUT, DELETE, HEAD",
});
if (request.statusCode == 200) {
Map<String, String> headers = request.headers;
if (headers.containsKey("Origin")) {
var origin = headers['Origin'];
print("your result: " + origin.toString());
}
file.writeAsBytes(request.bodyBytes);
}
return file;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | JJGV |