Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Downloading .wav file in Firefox(in others working) using Angular Observable throwing "Http failure response: 0 Unknown Error failed" error

more options

Sample Code Snippet:

"downloadFile(payLoad: any): Observable	<HttpResponse<any>> {
   return this.http.post(this.fileDownloadUrl, payLoad,
     { headers: { 'Content-Type': 'application/json' }, observe: 'response', responseType: 'blob' });
 } "

This snippet is working for all other browsers except Firefox. I have tested it on Version 68.0.2 (64-bit), Version 69.0 (64-bit).

Can anyone help on the fix or any alternative way to download wav file in Angular 7?

Sample Code Snippet: "downloadFile(payLoad: any): Observable &lt;HttpResponse&lt;any&gt;&gt; { return this.http.post(this.fileDownloadUrl, payLoad, { headers: { 'Content-Type': 'application/json' }, observe: 'response', responseType: 'blob' }); } " This snippet is working for all other browsers except Firefox. I have tested it on Version 68.0.2 (64-bit), Version 69.0 (64-bit). Can anyone help on the fix or any alternative way to download wav file in Angular 7?

Modified by akashmittal

All Replies (2)

more options

Are the CORS headers set properly? Could you show your header list?

more options

Hi Mesko,

The application don't have any 3rd party dependency thus we have blocked CORS here due to security reason. All resources that application needs are there on single server on which it is deployed. I am sharing the headers for your reference:

Request Header: Host: ******************* User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0 Accept: application/json, text/plain, */* Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate, br Content-Type: application/json X-CSRF-TOKEN: 66f60688-b6ae-44ff-96f1-0ee3cf9c595b Content-Length: 74 DNT: 1 Connection: keep-alive Referer: https://******************************** Cookie: JSESSIONID=ADC4844F95A6711A5AE383D95CD3A424; X-CSRF-TOKEN=66f60688-b6ae-44ff-96f1-0ee3cf9c595b Pragma: no-cache Cache-Control: no-cache

Response Header: HTTP/1.1 200 X-CSRF-HEADER: X-CSRF-TOKEN X-CSRF-PARAM: _csrf X-CSRF-TOKEN: 66f60688-b6ae-44ff-96f1-0ee3cf9c595b Set-Cookie: X-CSRF-TOKEN=66f60688-b6ae-44ff-96f1-0ee3cf9c595b; Path=/; Secure Content-disposition: attachment;filename=temp.wav X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block Cache-Control: no-cache, no-store, max-age=0, must-revalidate Pragma: no-cache Expires: 0 Strict-Transport-Security: max-age=31536000 ; includeSubDomains X-Frame-Options: SAMEORIGIN Content-Security-Policy: default-src 'self' data: 'unsafe-eval' 'unsafe-inline'; Transfer-Encoding: chunked Date: Mon, 09 Sep 2019 06:25:15 GMT

Hope you can help us on where we are going wrong.

Thanks

Modified by akashmittal