Search code examples
htmlhttpwebmime-types

Force browser to use specific Accept field in HTTP request


is it possible to enforce a web browser to use specific mime-type in html request?

<a type="application/pdf" href="https://url.com/">PDF</a> or <a type="text/html" href="https://url.com/">HTML</a> so here browser requests both times with text/html in accept field.


Solution

  • The only time you can control request headers is when the request is being made with XMLHttpRequest or Fetch.

    This problem is better solved by having distinct URLs.

    E.g.

    <a href=“http://example.com/example.pdf”>PDF</a>
    <a href=“http://example.com/example”>HTML</a>