You are correct, the Content-Type
header is all that matters.
In general, browsers don't see URLs as breaking down into parts like "directory", "filename", and "extension"; in fact, HTTP has no concept of "files" at all. Rather, a URL is just a string to be sent to some server; the server then responds with some content, and a header indicating how that content should be interpreted.
Whether you reference your SVG as /icons
, or /icons.php
, or /icons.awesome
, the browser will just send that URL, and have no idea if the response is coming from a file with that name, or a different name, or generated on demand.
You can see this in action on this very page: the URL doesn't end ".html", but the browser is rendering the HTML. That's not relying on some default built into the browser, it's because the Content-Type
header that Stack Overflow's server sent identified the returned content as text/html
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…