Chrome在下载PDF时发送两个请求(并取消其中一个请求) [英] Chrome sends two requests when downloading a PDF (and cancels one of them)

查看:147
本文介绍了Chrome在下载PDF时发送两个请求(并取消其中一个请求)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,无论何时您使用chrome下载PDF,它都会一直提出两个请求,而其中一个请求是正确的。这导致请求在我的Web应用程序中注册了两次,这是不需要的。有没有办法让Chrome浏览器只发出一个PDF请求?



我现在已经研究了这个主题,而且我还没有找到足够的答案。密切相关的答案表明,问题在于Chrome正在寻找一个网站图标,但网络标签显示它实际上提交了两次相同的请求,然后取消了第二个请求。



有没有办法阻止Chrome提出第二次请求?



以下是我通过Google找到的一个随机PDF文件的链接,点击时应该演示行为。我会在devtools上张贴我的网络标签的图片,但这是我在stackoverflow上的第一篇文章,并且该网站禁止我上传图片。



https://www.adobe.com/enterprise/accessibility/pdfs/acro6_pg_ue.pdf

解决方案

它看起来像Chrome中的一个bug: https://bugs.chromium.org/p/chromium/issues/detail?id=587709



问题在于,Chrome在加载返回PDF流的iframe时,会在该iframe中写入一个嵌入标记,该标记又包含与iframe相同的网址。这会再次触发对该网址的请求,但Chrome立即取消该网址。 (见网络标签)
但到那时,损坏已经完成。

我们在这里有同样的问题,并且它不会发生在Firefox或IE。



我们仍然在寻找解决这个问题的好方法。


I noticed that whenever you download a PDF in chrome, it consistently makes two requests, and the ncancels one of them. This is causing the request to be registered twice in my Web app, which don't want. Is there a way to get Chrome to only make one request for PDFs?

I've researched this topic quite a bit now, and I have not found a sufficient answer. Closely-related answers suggest that the problem is that Chrome is looking for a favicon, but the network tab shows that it is actually making the same request twice, and then canceling the second request.

Is there a way to prevent Chrome from making the second request?

Below is a link of a random PDF file that I found through Google which when clicked should demonstrates the behavior. I would've posted a picture of my network tab in devtools but this is my first post on stackoverflow, and the site is prohibiting me from uploading a picture.

https://www.adobe.com/enterprise/accessibility/pdfs/acro6_pg_ue.pdf

解决方案

It looks like a bug in Chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=587709

The problem is that Chrome, when it loads an iframe that returns a PDF stream, writes an "embed" tag inside that iframe which again contains the same URL as the iframe. This triggers a request for that URL again, but Chrome immediately cancels it. (see the network tab) But by that time, the damage is done.

We have the same issue here, and it does not occur in Firefox or IE.

We're still looking for a good solution to this problem.

这篇关于Chrome在下载PDF时发送两个请求(并取消其中一个请求)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆