相同的URL提供不同的内容 - 为什么?

时间:2014-04-07 20:15:53

标签: javascript url cookies browser content-type

如果您已登录,则此URL:https://download.ama-assn.org/resources/doc/usan/x-pub/usan-february-2014-newsletter.pdf将返回html页面:

<div id="dlblock">
    <a href="http://www.ama-assn.org">
        <img src="https://www.ama-assn.org/resources/images/header/ama-logo.png" border="0">
    </a><br><br>
    You are about to download<br>
    <strong>
         <a id="file-link" href="/resources/doc/usan/x-pub/usan-february-2014-newsletter.pdf" target="_blank">usan-february-2014-newsletter.pdf</a>
    </strong>
    If you are not automatically redirected, please 
    <a href="/resources/doc/usan/x-pub/usan-february-2014-newsletter.pdf" target="_blank">click here</a> 
    to begin your download.   <br><br>
    <small>Copyright 1995-2014 
        <a href="http://www.ama-assn.org">American Medical Association</a> All rights reserved.
    </small>

如果您点击此页面上的链接(并且该网址是刚在新窗口中打开的同一页面),您将获得pdf。

我不明白服务器如何决定何时提供html以及何时提供pdf - 这是如何实现的?

1 个答案:

答案 0 :(得分:1)

服务器可能会读取http referer请求标头,如果它与页面的网址匹配,请改为提供PDF版本。