Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
Hi Guys,

You know how here at CP the download links on articles lead you to a normal CP "download" page even though the address in the URL bar ends with ".zip" and is the URL of the file you are downloading?

Could someone throw me a lead on how this sort of behaviour is implemented so I can do the same on my own site? I don't know the terms I should be googling for.

Cheers. :-)
Posted
Comments
[no name] 4-Oct-14 21:01pm    
URL rewriting?
Mitchell J. 4-Oct-14 21:04pm    
Yeah that's what I suspected might be involved... Thanks.
[no name] 4-Oct-14 21:11pm    
np

1 solution

The file name does not affect the content type. In other words, the URL which ends with ".zip" can provide a resource which is actually HTML, or anything else. Here is how it is implemented: "content-type" is one of the HTTP headers which defines further processing of an HTTP response.
Please see:
http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol[^],
http://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Response_fields[^],
http://en.wikipedia.org/wiki/Internet_media_type[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900