Chrome failed to download word

This article gives you a comprehensive understanding of Java object serialization and deserialization>>>

Background: this problem occurs in the development and testing phase of the project

Recurrence: there has been no problem in the development and debugging process. The local download of Excel, word and PDF is perfect. However, after the service is deployed to the server, the download of chrome in the test environment always fails, indicating network errors

  

At this time, we trace the problem. During the local test, we find that every download will have a problem warning: resource interpreted as document but transferred with MIME type application/octet stream

Baidu, most of them are modifying content-type, but no matter what type of modification it is, the packet is displayed back to the corresponding type, but download is not successful (it has to make complaints about Baidu, really is advertising first-class). p>

Switch to Bing and successfully find a solution: add the header information content length, , in which bytes is the binary stream file to download

The reason for this is that the download of byte stream is restricted by the advanced version of chrome, and the length of byte stream should be declared in the header information( What are the specific restrictions here?I’ll update it later when I find out the exact statement.)

Update on August 23, 2019: words exported in this way are lost. The length of the stream added in the header is only the length of the body (bytes. Length), and the length of the header needs to be added. I added 5000 here, which is also measured a little bit

Update on December 13, 2019: in the past two days, a user reported that the export of word failed, . First, I used my computer’s Chrome test – no problem, and asked him about the browser version he used – the latest version of chrome 79. After downloading, I tried, and sure enough, there was a problem, and I couldn’t find the reason through local debugging

Thinking about whether it is the length of the byte stream, I deleted the 5000 I added and tested it successfully. There was no loss of words! I guess some bugs have been fixed after chrome upgrade. The length of header information should not be added to the length of byte stream

Record as a problem only

Address: https://blog.csdn.net/qq_ 34720759/article/details/79189480

Similar Posts: