gpt4 book ai didi

python - 网络故障”从 chrome 和 Edge 浏览器下载 PDF 但它在 IE 和 firefox 中工作

转载 作者:行者123 更新时间:2023-12-05 06:48:11 25 4
gpt4 key购买 nike

在我当前的应用程序中,当我单击PDF View 按钮时,PDF 将在新窗口中打开,之后我们可以下载PDF 文件。在下载期间,它会为 chrome 和 Edge 浏览器抛出错误,但它适用于 IE 和 Firefox。我搜索了谷歌,发现使用浏览器内容设置修复了类似类型的问题。如果我应用相同,那次 PDF View 选项直接下载 pdf 文件,但预期的行为是首先我们可以在下载 pdf 文件后查看 pdf。

type_parameter = "application/pdf; charset=UTF-8"

header = [("Content-Disposition", "filename=%s" % file_name),('Content-type',
'application/pdf; charset="UTF-8"')]

谁能告诉我如何解决这个问题?

图片 1:

enter image description here

网络失败错误:

enter image description here

提前致谢

Python 代码:

content = create_pdf_file()
type= "application/pdf"
h= [("Content-Disposition", "filename=%s" % file_name),('Content-type', 'application/pdf; charset="UTF-8"')]
self._ctx.iLib.forward("display", content, type, h)

显示.tmpl:

#def __call__(data, Ctype="application/pdf", h=None)
*##slurp
#set self.Ctype= Ctype
#if not h
#set h= []
#end if
#for name, value in h:
#if name.lower() == 'content-type':
#set self.Ctype= value
#silent $headers.remove((name, value))
#end if
#end for
#set self.h= h
#return data

最佳答案

更改 Web 服务器或响应 header 中的 PDF MIME 类型

application/pdf
application/octet-stream

这个问题是在启用 gzip 压缩和/或 HTTP/2 时出现的

为 SSL 连接启用 http/2 是一个非常有值(value)的性能设置。然而,http2 期望报告的大小与网络服务器报告的流媒体内容相匹配。

关于python - 网络故障”从 chrome 和 Edge 浏览器下载 PDF 但它在 IE 和 firefox 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66869701/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com