HTTP响应头的执行顺序? [英] Execution order of Http Response headers?

查看:1204
本文介绍了HTTP响应头的执行顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到的 这个插件 的哪个下载使用Ajax的和文件的其他一些后备的技术。

I saw this plugin which download files using Ajax and some other fallback techniques.

但是,由于阿贾克斯下载文件功能在所有的浏览器都支持,他用的是iframe的伎俩。 (这是pretty容易实现)

But since ajax download file feature is not supported in all browsers , he used a trick with Iframe. ( which is pretty easy to implement)

但有一件事引起我的注意:

But one thing caught my eye :

他还补充它告诉你,当文件完成的一个选项
  下载。

He also added an option which tells you when the file has finished download.

他通过饼干做到了。他调查,看是否饼干通过的setInterval 。只要的 cookie不存在 - 该文件没有完成下载(当饼干为$。 p $ psent - 该文件下载)

He did it via cookie. He polls to see if the cookie via setInterval. as long as the cookie does not exist - the file wasn't finish download.( and when the cookie is present - the file has downloaded)

因此​​,对下载文件的标题是:

So the header for downloading a file is:

内容处置:附件;文件名= Report0.pdf

和他补充说:

设置Cookie:fileDownload = TRUE; PATH = /

但转念一想 - 谁说,的Set-Cookie 被称为 文件已经完成下载后?

But then I thought - who said that set-cookie is called after the file has finish downloaded ?

问题:

看一下实际的标题:

1 - 是否浏览器的消化的根据出现的实际顺序每头?

1 - Does the browser digest each header according to the actual order of appearance ?

2 - 是否有必须出现的之前以其他任何标题标题

2 - Are there any headers which must appear prior to other headers ?

3 - 是否每个头的摘要 - 块摘要直到目前hedare消化完毕?我的意思是:做行内容处置:附件;文件名= 1.JPG $ P $从消化下一个头pvents浏览器 - 直到文件名= 1.JPG 加载完成?

3 - Does the digest of each header - blocks the digest until current hedare digest is completed ? I mean : does the line content-disposition:attachment;filename=1.jpg prevents the browser from digesting the next header - until the filename=1.jpg is finished loading ?

NB

我也试着通过的提琴手调查,但我没有得到任何结论。(我的意思是我如何在提琴手测试吗?)

推荐答案

您说的没错是持怀疑态度。

You're right to be skeptical.

有没有要求,即客户端等待响应体是完整的评估设置Cookie 报头preceded身体,其实很好的理由有相信大多数浏览器将设置cookie之前身体完整(因为很多网页会看的document.cookie 在JavaScript的HTML页面内)。

There's no requirement that a client wait until the response body is complete to evaluate the Set-Cookie header that preceded the body, and there's in fact good reason to believe that most browsers will set the cookie before the body is complete (since many web pages will look at document.cookie in JavaScript inside a HTML page).

其实,我测试(使用MeddlerScript,你可以在这里看到: http://pastebin.com/SUwCFyxS),发现IE,Chrome和Firefox的所有设置Cookie在下载完成之前,并设置Cookie即使用户点击取消的下载。

In fact, I tested this (using a MeddlerScript you can see here: http://pastebin.com/SUwCFyxS) and found that IE, Chrome and Firefox all set the cookie before the download completes, and set the cookie even if the user hits "Cancel" on the download.

HTTP规范包括的概念预告(这是响应正文之后出现一个标题),但这些都很少使用,在很多客户不支持(例如:的WinINET / IE)。如果客户端的没有的支持拖车,服务器后的可以发送的Set-Cookie头的体内这将意味着客户端无法看到它,直到身体下载完毕。

The HTTP specification includes the notion of a Trailer (which is a header that appears after the response body) but these are little used and not supported in many clients (e.g. WinINET/IE). If the client did support Trailers, the server could send the Set-Cookie header after the body which would mean that the client couldn't see it until the body finished downloading.

这篇关于HTTP响应头的执行顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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