搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

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

  • 2 个回答
  • 1 人有此问题
  • 1 次查看
  • 最后回复者为 akashmittal

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?

由akashmittal于修改

所有回复 (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

由akashmittal于修改