使用javascript XMLHttpRequest,我可以轻松地使用getAllResponseHeaders()方法获取标头
var req = new XMLHttpRequest();
req.open('GET', document.location, false);
req.send(null);
var headers = req.getAllResponseHeaders().toLowerCase();
得到类似以下结果:
accept-ranges: bytes
access-control-allow-origin: *
content-length: 4546
content-type: text/html; charset=UTF-8
date: Mon, 18 May 2020 04:24:30 GMT
etag: W/"11c2-u8XhnlVk5uwUwaHTXsnarcbbBQw"
x-powered-by: Express
现在,我想在Angular中使用它,但是当我使用HttpClient启动请求时,我无法弄清楚如何获取这些值。