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

📄 headers.html

📁 perl教程
💻 HTML
📖 第 1 页 / 共 2 页
字号:
an argument to the method.  The old header value is always returned.
If the given header did not exist then <a href="../../lib/Pod/perlfunc.html#item_undef"><code>undef</code></a> is returned.</p>
<p>Methods that deal with dates/times always convert their value to system
time (seconds since Jan 1, 1970) and they also expect this kind of
value when the header value is set.</p>
<dl>
<dt><strong><a name="item_date">$h-&gt;date</a></strong>

<dd>
<p>This header represents the date and time at which the message was
originated. <em>E.g.</em>:</p>
</dd>
<dd>
<pre>
  <span class="variable">$h</span><span class="operator">-&gt;</span><span class="variable">date</span><span class="operator">(</span><span class="keyword">time</span><span class="operator">);</span>  <span class="comment"># set current date</span>
</pre>
</dd>
</li>
<dt><strong><a name="item_expires">$h-&gt;expires</a></strong>

<dd>
<p>This header gives the date and time after which the entity should be
considered stale.</p>
</dd>
</li>
<dt><strong><a name="item_if_modified_since">$h-&gt;if_modified_since</a></strong>

<dt><strong><a name="item_if_unmodified_since">$h-&gt;if_unmodified_since</a></strong>

<dd>
<p>These header fields are used to make a request conditional.  If the requested
resource has (or has not) been modified since the time specified in this field,
then the server will return a <code>304 Not Modified</code> response instead of
the document itself.</p>
</dd>
</li>
<dt><strong><a name="item_last_modified">$h-&gt;last_modified</a></strong>

<dd>
<p>This header indicates the date and time at which the resource was last
modified. <em>E.g.</em>:</p>
</dd>
<dd>
<pre>
  <span class="comment"># check if document is more than 1 hour old</span>
  <span class="keyword">if</span> <span class="operator">(</span><span class="keyword">my</span> <span class="variable">$last_mod</span> <span class="operator">=</span> <span class="variable">$h</span><span class="operator">-&gt;</span><span class="variable">last_modified</span><span class="operator">)</span> <span class="operator">{</span>
      <span class="keyword">if</span> <span class="operator">(</span><span class="variable">$last_mod</span> <span class="operator">&lt;</span> <span class="keyword">time</span> <span class="operator">-</span> <span class="number">60</span><span class="operator">*</span><span class="number">60</span><span class="operator">)</span> <span class="operator">{</span>
          <span class="operator">...</span>
      <span class="operator">}</span>
  <span class="operator">}</span>
</pre>
</dd>
</li>
<dt><strong><a name="item_content_type">$h-&gt;content_type</a></strong>

<dd>
<p>The Content-Type header field indicates the media type of the message
content. <em>E.g.</em>:</p>
</dd>
<dd>
<pre>
  <span class="variable">$h</span><span class="operator">-&gt;</span><span class="variable">content_type</span><span class="operator">(</span><span class="string">'text/html'</span><span class="operator">);</span>
</pre>
</dd>
<dd>
<p>The value returned will be converted to lower case, and potential
parameters will be chopped off and returned as a separate value if in
an array context.  If there is no such header field, then the empty
string is returned.  This makes it safe to do the following:</p>
</dd>
<dd>
<pre>
  <span class="keyword">if</span> <span class="operator">(</span><span class="variable">$h</span><span class="operator">-&gt;</span><span class="variable">content_type</span> <span class="keyword">eq</span> <span class="string">'text/html'</span><span class="operator">)</span> <span class="operator">{</span>
     <span class="comment"># we enter this place even if the real header value happens to</span>
     <span class="comment"># be 'TEXT/HTML; version=3.0'</span>
     <span class="operator">...</span>
  <span class="operator">}</span>
</pre>
</dd>
</li>
<dt><strong><a name="item_content_encoding">$h-&gt;content_encoding</a></strong>

<dd>
<p>The Content-Encoding header field is used as a modifier to the
media type.  When present, its value indicates what additional
encoding mechanism has been applied to the resource.</p>
</dd>
</li>
<dt><strong><a name="item_content_length">$h-&gt;content_length</a></strong>

<dd>
<p>A decimal number indicating the size in bytes of the message content.</p>
</dd>
</li>
<dt><strong><a name="item_content_language">$h-&gt;content_language</a></strong>

<dd>
<p>The natural <code>language(s)</code> of the intended audience for the message
content.  The value is one or more language tags as defined by RFC
1766.  Eg. &quot;no&quot; for some kind of Norwegian and &quot;en-US&quot; for English the
way it is written in the US.</p>
</dd>
</li>
<dt><strong><a name="item_title">$h-&gt;title</a></strong>

<dd>
<p>The title of the document.  In libwww-perl this header will be
initialized automatically from the &lt;TITLE&gt;...&lt;/TITLE&gt; element
of HTML documents.  <em>This header is no longer part of the HTTP
standard.</em></p>
</dd>
</li>
<dt><strong><a name="item_user_agent">$h-&gt;user_agent</a></strong>

<dd>
<p>This header field is used in request messages and contains information
about the user agent originating the request.  <em>E.g.</em>:</p>
</dd>
<dd>
<pre>
  <span class="variable">$h</span><span class="operator">-&gt;</span><span class="variable">user_agent</span><span class="operator">(</span><span class="string">'Mozilla/1.2'</span><span class="operator">);</span>
</pre>
</dd>
</li>
<dt><strong><a name="item_server">$h-&gt;server</a></strong>

<dd>
<p>The server header field contains information about the software being
used by the originating server program handling the request.</p>
</dd>
</li>
<dt><strong><a name="item_from">$h-&gt;from</a></strong>

<dd>
<p>This header should contain an Internet e-mail address for the human
user who controls the requesting user agent.  The address should be
machine-usable, as defined by RFC822.  E.g.:</p>
</dd>
<dd>
<pre>
  <span class="variable">$h</span><span class="operator">-&gt;</span><span class="variable">from</span><span class="operator">(</span><span class="string">'King Kong &lt;king@kong.com&gt;'</span><span class="operator">);</span>
</pre>
</dd>
<dd>
<p><em>This header is no longer part of the HTTP standard.</em></p>
</dd>
</li>
<dt><strong><a name="item_referer">$h-&gt;referer</a></strong>

<dd>
<p>Used to specify the address (URI) of the document from which the
requested resource address was obtained.</p>
</dd>
<dd>
<p>The &quot;Free On-line Dictionary of Computing&quot; as this to say about the
word <em>referer</em>:</p>
</dd>
<dd>
<pre>
     &lt;World-Wide Web&gt; A misspelling of &quot;referrer&quot; which
     somehow made it into the {HTTP} standard.  A given {web
     page}'s referer (sic) is the {URL} of whatever web page
     contains the link that the user followed to the current
     page.  Most browsers pass this information as part of a
     request.</pre>
</dd>
<dd>
<pre>
     (1998-10-19)</pre>
</dd>
<dd>
<p>By popular demand <code>referrer</code> exists as an alias for this method so you
can avoid this misspelling in your programs and still send the right
thing on the wire.</p>
</dd>
<dd>
<p>When setting the referrer, this method removes the fragment from the
given URI if it is present, as mandated by RFC2616.  Note that
the removal does <em>not</em> happen automatically if using the header(),
<a href="#item_push_header"><code>push_header()</code></a> or <a href="#item_init_header"><code>init_header()</code></a> methods to set the referrer.</p>
</dd>
</li>
<dt><strong><a name="item_www_authenticate">$h-&gt;www_authenticate</a></strong>

<dd>
<p>This header must be included as part of a <code>401 Unauthorized</code> response.
The field value consist of a challenge that indicates the
authentication scheme and parameters applicable to the requested URI.</p>
</dd>
</li>
<dt><strong><a name="item_proxy_authenticate">$h-&gt;proxy_authenticate</a></strong>

<dd>
<p>This header must be included in a <code>407 Proxy Authentication Required</code>
response.</p>
</dd>
</li>
<dt><strong><a name="item_authorization">$h-&gt;authorization</a></strong>

<dt><strong><a name="item_proxy_authorization">$h-&gt;proxy_authorization</a></strong>

<dd>
<p>A user agent that wishes to authenticate itself with a server or a
proxy, may do so by including these headers.</p>
</dd>
</li>
<dt><strong><a name="item_authorization_basic">$h-&gt;authorization_basic</a></strong>

<dd>
<p>This method is used to get or set an authorization header that use the
&quot;Basic Authentication Scheme&quot;.  In array context it will return two
values; the user name and the password.  In scalar context it will
return <em>&quot;uname:password&quot;</em> as a single string value.</p>
</dd>
<dd>
<p>When used to set the header value, it expects two arguments.  <em>E.g.</em>:</p>
</dd>
<dd>
<pre>
  <span class="variable">$h</span><span class="operator">-&gt;</span><span class="variable">authorization_basic</span><span class="operator">(</span><span class="variable">$uname</span><span class="operator">,</span> <span class="variable">$password</span><span class="operator">);</span>
</pre>
</dd>
<dd>
<p>The method will croak if the $uname contains a colon ':'.</p>
</dd>
</li>
<dt><strong><a name="item_proxy_authorization_basic">$h-&gt;proxy_authorization_basic</a></strong>

<dd>
<p>Same as <a href="#item_authorization_basic"><code>authorization_basic()</code></a> but will set the &quot;Proxy-Authorization&quot;
header instead.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="noncanonicalized_field_names">NON-CANONICALIZED FIELD NAMES</a></h1>
<p>The header field name spelling is normally canonicalized including the
'_' to '-' translation.  There are some application where this is not
appropriate.  Prefixing field names with ':' allow you to force a
specific spelling.  For example if you really want a header field name
to show up as <code>foo_bar</code> instead of &quot;Foo-Bar&quot;, you might set it like
this:</p>
<pre>
  <span class="variable">$h</span><span class="operator">-&gt;</span><span class="variable">header</span><span class="operator">(</span><span class="string">":foo_bar"</span> <span class="operator">=&gt;</span> <span class="number">1</span><span class="operator">);</span>
</pre>
<p>These field names are returned with the ':' intact for
$h-&gt;header_field_names and the $h-&gt;scan callback, but the colons do
not show in $h-&gt;as_string.</p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Copyright 1995-2005 Gisle Aas.</p>
<p>This library is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.</p>

</body>

</html>

⌨️ 快捷键说明

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