⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 content-negotiation.html.en

📁 Apache_2.0.59-Openssl_0.9 配置tomcat. Apache_2.0.59-Openssl_0.9 配置tomcat.
💻 EN
📖 第 1 页 / 共 3 页
字号:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
              This file is generated from xml source: DO NOT EDIT
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
      -->
<title>Content Negotiation - Apache HTTP Server</title>
<link href="./style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
<link href="./style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
<link href="./style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
<link href="./images/favicon.ico" rel="shortcut icon" /></head>
<body id="manual-page"><div id="page-header">
<p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p>
<p class="apache">Apache HTTP Server Version 2.0</p>
<img alt="" src="./images/feather.gif" /></div>
<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="./images/left.gif" /></a></div>
<div id="path">
<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="./">Version 2.0</a></div><div id="page-content"><div id="preamble"><h1>Content Negotiation</h1>
<div class="toplang">
<p><span>Available Languages: </span><a href="./en/content-negotiation.html" title="English">&nbsp;en&nbsp;</a> |
<a href="./fr/content-negotiation.html" hreflang="fr" rel="alternate" title="Fran鏰is">&nbsp;fr&nbsp;</a> |
<a href="./ja/content-negotiation.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
<a href="./ko/content-negotiation.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p>
</div>


    <p>Apache supports content negotiation as described in
    the HTTP/1.1 specification. It can choose the best
    representation of a resource based on the browser-supplied
    preferences for media type, languages, character set and
    encoding. It also implements a couple of features to give
    more intelligent handling of requests from browsers that send
    incomplete negotiation information.</p>

    <p>Content negotiation is provided by the
    <code class="module"><a href="./mod/mod_negotiation.html">mod_negotiation</a></code> module, which is compiled in
    by default.</p>
</div>
<div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#about">About Content Negotiation</a></li>
<li><img alt="" src="./images/down.gif" /> <a href="#negotiation">Negotiation in Apache</a></li>
<li><img alt="" src="./images/down.gif" /> <a href="#methods">The Negotiation Methods</a></li>
<li><img alt="" src="./images/down.gif" /> <a href="#better">Fiddling with Quality
    Values</a></li>
<li><img alt="" src="./images/down.gif" /> <a href="#extensions">Extensions to Transparent Content
Negotiation</a></li>
<li><img alt="" src="./images/down.gif" /> <a href="#naming">Note on hyperlinks and naming conventions</a></li>
<li><img alt="" src="./images/down.gif" /> <a href="#caching">Note on Caching</a></li>
<li><img alt="" src="./images/down.gif" /> <a href="#more">More Information</a></li>
</ul></div>
<div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
<div class="section">
<h2><a name="about" id="about">About Content Negotiation</a></h2>

    <p>A resource may be available in several different
    representations. For example, it might be available in
    different languages or different media types, or a combination.
    One way of selecting the most appropriate choice is to give the
    user an index page, and let them select. However it is often
    possible for the server to choose automatically. This works
    because browsers can send, as part of each request, information
    about what representations they prefer. For example, a browser
    could indicate that it would like to see information in French,
    if possible, else English will do. Browsers indicate their
    preferences by headers in the request. To request only French
    representations, the browser would send</p>

<div class="example"><p><code>Accept-Language: fr</code></p></div>

    <p>Note that this preference will only be applied when there is
    a choice of representations and they vary by language.</p>

    <p>As an example of a more complex request, this browser has
    been configured to accept French and English, but prefer
    French, and to accept various media types, preferring HTML over
    plain text or other text types, and preferring GIF or JPEG over
    other media types, but also allowing any other media type as a
    last resort:</p>

<div class="example"><p><code>
  Accept-Language: fr; q=1.0, en; q=0.5<br />
  Accept: text/html; q=1.0, text/*; q=0.8, image/gif; q=0.6, image/jpeg; q=0.6, image/*; q=0.5, */*; q=0.1
</code></p></div>

    <p>Apache supports 'server driven' content negotiation, as
    defined in the HTTP/1.1 specification. It fully supports the
    <code>Accept</code>, <code>Accept-Language</code>,
    <code>Accept-Charset</code> and<code>Accept-Encoding</code> 
    request headers. Apache also supports 'transparent'
    content negotiation, which is an experimental negotiation
    protocol defined in RFC 2295 and RFC 2296. It does not offer
    support for 'feature negotiation' as defined in these RFCs.</p>

    <p>A <strong>resource</strong> is a conceptual entity
    identified by a URI (RFC 2396). An HTTP server like Apache
    provides access to <strong>representations</strong> of the
    resource(s) within its namespace, with each representation in
    the form of a sequence of bytes with a defined media type,
    character set, encoding, etc. Each resource may be associated
    with zero, one, or more than one representation at any given
    time. If multiple representations are available, the resource
    is referred to as <strong>negotiable</strong> and each of its
    representations is termed a <strong>variant</strong>. The ways
    in which the variants for a negotiable resource vary are called
    the <strong>dimensions</strong> of negotiation.</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
<div class="section">
<h2><a name="negotiation" id="negotiation">Negotiation in Apache</a></h2>

    <p>In order to negotiate a resource, the server needs to be
    given information about each of the variants. This is done in
    one of two ways:</p>

    <ul>
      <li>Using a type map (<em>i.e.</em>, a <code>*.var</code>
      file) which names the files containing the variants
      explicitly, or</li>

      <li>Using a 'MultiViews' search, where the server does an
      implicit filename pattern match and chooses from among the
      results.</li>
    </ul>

   <h3><a name="type-map" id="type-map">Using a type-map file</a></h3>

    <p>A type map is a document which is associated with the
    handler named <code>type-map</code> (or, for
    backwards-compatibility with older Apache configurations, the
    MIME type <code>application/x-type-map</code>). Note that to
    use this feature, you must have a handler set in the
    configuration that defines a file suffix as
    <code>type-map</code>; this is best done with</p>

<div class="example"><p><code>AddHandler type-map .var</code></p></div>

    <p>in the server configuration file.</p>

    <p>Type map files should have the same name as the resource
    which they are describing, and have an entry for each available
    variant; these entries consist of contiguous HTTP-format header
    lines. Entries for different variants are separated by blank
    lines. Blank lines are illegal within an entry. It is
    conventional to begin a map file with an entry for the combined
    entity as a whole (although this is not required, and if
    present will be ignored). An example map file is shown below.
    This file would be named <code>foo.var</code>, as it describes
    a resource named <code>foo</code>.</p>

<div class="example"><p><code>
  URI: foo<br />
<br />
  URI: foo.en.html<br />
  Content-type: text/html<br />
  Content-language: en<br />
<br />
  URI: foo.fr.de.html<br />
  Content-type: text/html;charset=iso-8859-2<br />
  Content-language: fr, de<br />
</code></p></div>
    <p>Note also that a typemap file will take precedence over the
    filename's extension, even when Multiviews is on. If the
    variants have different source qualities, that may be indicated
    by the "qs" parameter to the media type, as in this picture
    (available as JPEG, GIF, or ASCII-art): </p>

<div class="example"><p><code>
  URI: foo<br />
<br />
  URI: foo.jpeg<br />
  Content-type: image/jpeg; qs=0.8<br />
<br />
  URI: foo.gif<br />
  Content-type: image/gif; qs=0.5<br />
<br />
  URI: foo.txt<br />
  Content-type: text/plain; qs=0.01<br />
</code></p></div>

    <p>qs values can vary in the range 0.000 to 1.000. Note that
    any variant with a qs value of 0.000 will never be chosen.
    Variants with no 'qs' parameter value are given a qs factor of
    1.0. The qs parameter indicates the relative 'quality' of this
    variant compared to the other available variants, independent
    of the client's capabilities. For example, a JPEG file is
    usually of higher source quality than an ASCII file if it is
    attempting to represent a photograph. However, if the resource
    being represented is an original ASCII art, then an ASCII
    representation would have a higher source quality than a JPEG
    representation. A qs value is therefore specific to a given
    variant depending on the nature of the resource it
    represents.</p>

    <p>The full list of headers recognized is available in the <a href="mod/mod_negotiation.html#typemaps">mod_negotation
    typemap</a> documentation.</p>


<h3><a name="multiviews" id="multiviews">Multiviews</a></h3>

    <p><code>MultiViews</code> is a per-directory option, meaning it
    can be set with an <code class="directive"><a href="./mod/core.html#options">Options</a></code>
    directive within a <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code>, <code class="directive"><a href="./mod/core.html#location">&lt;Location&gt;</a></code> or <code class="directive"><a href="./mod/core.html#files">&lt;Files&gt;</a></code> section in
    <code>httpd.conf</code>, or (if <code class="directive"><a href="./mod/core.html#allowoverride">AllowOverride</a></code> is properly set) in
    <code>.htaccess</code> files. Note that <code>Options All</code>
    does not set <code>MultiViews</code>; you have to ask for it by
    name.</p>

    <p>The effect of <code>MultiViews</code> is as follows: if the
    server receives a request for <code>/some/dir/foo</code>, if
    <code>/some/dir</code> has <code>MultiViews</code> enabled, and
    <code>/some/dir/foo</code> does <em>not</em> exist, then the
    server reads the directory looking for files named foo.*, and
    effectively fakes up a type map which names all those files,
    assigning them the same media types and content-encodings it
    would have if the client had asked for one of them by name. It
    then chooses the best match to the client's requirements.</p>

    <p><code>MultiViews</code> may also apply to searches for the file
    named by the <code class="directive"><a href="./mod/mod_dir.html#directoryindex">DirectoryIndex</a></code> directive, if the
    server is trying to index a directory. If the configuration files
    specify</p>
<div class="example"><p><code>DirectoryIndex index</code></p></div>
    <p>then the server will arbitrate between <code>index.html</code>
    and <code>index.html3</code> if both are present. If neither
    are present, and <code>index.cgi</code> is there, the server
    will run it.</p>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -