matth3o matth3o - 1 year ago 114
Dart Question

dart BrowserClient - how to read response headers?

I don't manage to read response headers using browser_client.dart :

import 'package:http/browser_client.dart';

var response =
await, headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}, body: body);
print('Response headers: ${response.headers}');

Thanks for your help.

Answer Source

The server needs to allow the browser to expose the headers by listing the headers in the Access-control-expose-headers response header, otherwise you can see them in the browser devtools but when you try to read them in code, the browser will suppress them.

See also

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download