Let me start by saying that I am aware that you can specify the Content-Disposition in the header and use either "attachment" or "inline" and this question is NOT about that (at least not directly).
I have a file with a .txt extension. I am noticing different browser behavior dependent on the content of that .txt file. If my file contains alphanumeric characters and I paste the location of the file into the URL bar of (say) Chrome, the file opens in the browser.
If my file contains an "SI" character the file is downloaded instead of opened in the browser.
At first I thought it might be because "SI" is a control code, but "CR" and "LF" are also control codes and the file displays in the browser when they are present. The file even opens in the Chrome when there is a "DC2" character present in the .txt file.
My question is: At the file content level, what determines whether or not a file is displayed or downloaded?
(I realize this may vary by browser, but if there is something that's at least somewhat reliable, it would be helpful to know)
Thanks in advance.
EDIT (based on answer from Sam):
When the "SI" or "DC2" character is in the first 1000 or so characters of the text file it will be downloaded, if those characters are after the first 1000 or so characters the file is displayed in the browser.