I have a WebService that returns a PDF file (byte []). I am returning the file name in the header of the response.
In Chrome I can see the 'Response Headers' values and see that all headers are there, including the file name. However, when I try to retrieve these values in Angular, I can not, because in headers comes only the "Content-Type: application / pdf".
getPdf(url: string){
this.http.get(url, {responseType: 'arraybuffer', observe:'response'})
.subscribe(data => {
console.log(data.headers.get('filename')); // Imprime: null
console.log(data.headers.keys()); // Imprime: ["Content-Type"]
this.downloadFile(data.body);
});
}
Response Headers displayed in browser:
Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:Origin, X-Request-Width, Content-Type, Accept, authCode
Access-Control-Allow-Origin:*
Connection:keep-alive
Content-Disposition:attachment; filename=arquivo.pdf
Content-Type:application/pdf
Date:Mon, 26 Nov 2018 14:23:37 GMT
filename:arquivo.pdf
Server:JBoss-EAP/7
Transfer-Encoding:chunked
X-Powered-By:Undertow/1
Does anyone know what's wrong? How do I retrieve this value?