I saw this plugin which download files using Ajax and some other fallback techniques.
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.
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:
Content-Disposition: attachment; filename=Report0.pdf
And he added :
Set-Cookie: fileDownload=true; path=/
But then I thought - who said that set-cookie
is called after the file has finish downloaded ?
Questions:
Looking at the actual headers :
1 - Does the browser digest each header according to the actual order of appearance ?
2 - Are there any headers which must appear prior to other headers ?
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
I've also tried investigate it via fiddler but I didn't get any conclusion.( I mean how can I test it in fiddler ?)