【发布时间】:2011-08-16 03:02:39
【问题描述】:
使用 Django,我正在从服务器发送一个 pdf 文件。如果我使用以下方式将其作为附件发送:
response['Content-Disposition'] = 'attachment; filename=test.pdf'
下载正常,但在 Chrome 控制台中出现错误:
GET http://12.345.678.09/vpas/?print_confirm=true undefined (undefined)
如果我在没有设置响应的 Content-Disposition 的情况下发送 pdf,则没有错误。这个错误的原因是什么,我该如何摆脱它?
这是 http(来自 Firefox - 无法从 Chrome 中获得更多详细信息):
http://12.345.678.09/vpas/?print_confirm=true&vpa_id_to_print=2355
GET /vpas/?print_confirm=true&vpa_id_to_print=2355 HTTP/1.1
Host: 12.345.678.09
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17 GTB7.1 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Cookie: sessionid=fdabaccd2a731fd459cd5d6c3f5004f1
Cache-Control: max-age=0
HTTP/1.1 200 OK
Server: nginx/0.5.33
Date: Mon, 02 May 2011 00:59:48 GMT
Content-Type: application/pdf
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Cookie
Content-Disposition: attachment;
Set-Cookie: sessionid=fdabaccd2a731fd459cd5d6c3f5004f1; expires=Mon, 02-May-2011 01:59:48 GMT; Max-Age=3600; Path=/
这是我可以从 Chrome 获得的 http:
Request URL:http://12.345.678.09/vpas/?print_confirm=true&vpa_id_to_print=2355
Request Headers
Accept:application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.60 Safari/534.24
Query String Parameters
print_confirm:true
vpa_id_to_print:2355
【问题讨论】:
-
如果您可以添加 HTTP 跟踪,或者至少打印出浏览器接收到的标头字段,将会很有帮助。
-
添加在上面。我不知道如何从 Chrome 中获取更详细的跟踪信息。
-
跟踪没有显示 Content-Disposition 中的文件名参数...
标签: django http pdf google-chrome