Is it possible to indicate whether an HTTP request arises from the "save link as" action?

Is there a way for the server to determine if a specific HTTP request was initiated by right-clicking and selecting "save link as ..." from the context menu in chrome (or its equivalent in other browsers).

For example, some header that is sent in one scenario, but not in others.

My initial guess is the answer: no, but it would be interesting to experiment with this type of behavior.


Why does anyone want to know this?

As a simplified example, suppose we have a view with a list of files, in which each of them refers to a different view, which essentially prints the contents of the file, as well as some metadata and offers the ability to download them.

Sometimes a user simply wants to save several of them and has to go back and forth between the item view and the list.

If she tried to use the context menu for this, as now, she, of course, would get the HTML source of the single-file view, and this is usually not the desired behavior (at least in our case).

I have an obvious option to add a “load” control for each item in the list or even in the user’s context menu, but if I could find such a script on the server, I could deliver the file itself, and not the user could right-click > save-link-as and get the contents of the file, and the list should not be cluttered with additional controls.


, GitHub ( ) Moodle ( ), , .

+4
1

, , , , , (Firefox):

Pragma: no-cache
Cache-Control: no-cache

.

:

, :

http://www.yoursite.com/test.csv

URL . , URL- - .

, , OnClick event (, , ), URL- JavaScript:

http://www.yoursite.com/test.csv?display=html

html ( , JavaScript , , ).

, GitHub ( ) Moodle ( ), , .

. , - .

+1

Source: https://habr.com/ru/post/1621752/


All Articles