1

Topic: We write the HTTP the server. To recognize download a file.

In HTML there are such tags: <a download href =...> and <a href =...> on the first tag the browser should understand that it will load a file under the specified link. But actually it depends on what answer gives a Web server. It can so to give a file as contents which the browser should open in the a window, instead of download. But how to understand to a Web server, what the client  under the link to download a file? Here, for example, requests which come to Web server GET / HTTP/1.1. Accept: text/html, application/xhtml+xml, */*. GET /www/files/file.txt HTTP/1.1. Accept: text/html, application/xhtml+xml, */*. The request of page first it simply by default the Second it under the link <a download href =...> or <a href =...> as the second request is visible does not differ from, whether we press under the link to open it or to download a file. How to be? Really  substring going after GET /www/files/file.txt about filename extension search. And for example if the tail is not.htm or.html html or other predetermined extension then to consider, what the request about file loading came? It is Somehow inconvenient... Whether could that inventors html build in keywords request...

2

Re: We write the HTTP the server. To recognize download a file.

Hello, Dimatec, you wrote: D> But how to understand to a Web server, what the client  under the link to download a file? I not absolutely understand, what for it generally to distinguish. How it still can get on this link? To copy? Well let copies, if wants. Than it is harmful? Whether D> could that inventors html build in keywords request... Probably, they supposed, what possibilities to build URI Add to URL under the link something like enough? mode=download

3

Re: We write the HTTP the server. To recognize download a file.

Not clearly that you want to make and in what a problem. To display or download - from the point of view of HTTP there is no difference, it is the browser solves, depending on different factors. The server gives those bytes which of it are requested by the client. If the given type and the user specially can display the browser does not ask to download, it displays, if cannot - downloads. For example any browser is able to draw PDF and displays it, any is not able and downloads it. The user  under the link the right button also selected "to Save a file under the link" - the browser saves this resource, even if there normal HTML.

4

Re: We write the HTTP the server. To recognize download a file.

Hello, vsb, you wrote: vsb> it is not clear that you want to make and in what a problem. To display or download - from the point of view of HTTP there is no difference, it is the browser solves, depending on different factors. The server gives those bytes which of it are requested by the client. If the given type and the user specially can display the browser does not ask to download, it displays, if cannot - downloads. For example any browser is able to draw PDF and displays it, any is not able and downloads it. The user  under the link the right button also selected "to Save a file under the link" - the browser saves this resource, even if there normal HTML. I will add. The server can give file MIME-type through Content-Type. Normally just on the extension of a given file. Or if the data is given by a script - from this title exposes. It will be the help to the browser what exactly in this data, and further all the same to the browser to decide - to suggest to download or try to display.

5

Re: We write the HTTP the server. To recognize download a file.

Hello, Dimatec, you wrote: Can it is not necessary, and? The server to write in sense. Them it is written in assortment. Whether D> could that inventors html build in keywords request... Because HTML it only for the client, for server HTTP.