uri.html

来自「perl教程」· HTML 代码 · 共 912 行 · 第 1/3 页

HTML
912 行
字号
<p>Like the <em>ldap</em> URI scheme, but uses a UNIX domain socket.  The
server methods are not supported, and the local socket path is
available as $uri-&gt;un_path.  The <em>ldapi</em> scheme is used by the
OpenLDAP package.  There is no real specification for it, but it is
mentioned in various OpenLDAP manual pages.</p>
</dd>
</li>
<dt><strong><a name="item_ldaps_3a"><strong>ldaps</strong>:</a></strong>

<dd>
<p>Like the <em>ldap</em> URI scheme, but uses an SSL connection.  This
scheme is deprecated, as the preferred way is to use the <em>start_tls</em>
mechanism.</p>
</dd>
</li>
<dt><strong><a name="item_mailto_3a"><strong>mailto</strong>:</a></strong>

<dd>
<p>The <em>mailto</em> URI scheme is specified in RFC 2368.  The scheme was
originally used to designate the Internet mailing address of an
individual or service.  It has (in RFC 2368) been extended to allow
setting of other mail header fields and the message body.</p>
</dd>
<dd>
<p><code>URI</code> objects belonging to the mailto scheme support the common
methods and the generic query methods.  In addition, they support the
following mailto-specific methods: $uri-&gt;to, $uri-&gt;headers.</p>
</dd>
</li>
<dt><strong><a name="item_mms_3a"><strong>mms</strong>:</a></strong>

<dd>
<p>The <em>mms</em> URL specification can be found at <a href="http://sdp.ppona.com/">http://sdp.ppona.com/</a>
<code>URI</code> objects belonging to the mms scheme support the common,
generic, and server methods, with the exception of userinfo and
query-related sub-components.</p>
</dd>
</li>
<dt><strong><a name="item_news_3a"><strong>news</strong>:</a></strong>

<dd>
<p>The <em>news</em>, <em>nntp</em> and <em>snews</em> URI schemes are specified in
&lt;draft-gilman-news-url-01&gt; and will hopefully be available as an RFC
2396 based specification soon.</p>
</dd>
<dd>
<p><code>URI</code> objects belonging to the news scheme support the common,
generic and server methods.  In addition, they provide some methods to
access the path: $uri-&gt;group and $uri-&gt;message.</p>
</dd>
</li>
<dt><strong><a name="item_nntp_3a"><strong>nntp</strong>:</a></strong>

<dd>
<p>See <em>news</em> scheme.</p>
</dd>
</li>
<dt><strong><a name="item_pop_3a"><strong>pop</strong>:</a></strong>

<dd>
<p>The <em>pop</em> URI scheme is specified in RFC 2384. The scheme is used to
reference a POP3 mailbox.</p>
</dd>
<dd>
<p><code>URI</code> objects belonging to the pop scheme support the common, generic
and server methods.  In addition, they provide two methods to access the
userinfo components: $uri-&gt;user and $uri-&gt;auth</p>
</dd>
</li>
<dt><strong><a name="item_rlogin_3a"><strong>rlogin</strong>:</a></strong>

<dd>
<p>An old specification of the <em>rlogin</em> URI scheme is found in RFC
1738. <code>URI</code> objects belonging to the rlogin scheme support the
common, generic and server methods.</p>
</dd>
</li>
<dt><strong><a name="item_rtsp_3a"><strong>rtsp</strong>:</a></strong>

<dd>
<p>The <em>rtsp</em> URL specification can be found in section 3.2 of RFC 2326.
<code>URI</code> objects belonging to the rtsp scheme support the common,
generic, and server methods, with the exception of userinfo and
query-related sub-components.</p>
</dd>
</li>
<dt><strong><a name="item_rtspu_3a"><strong>rtspu</strong>:</a></strong>

<dd>
<p>The <em>rtspu</em> URI scheme is used to talk to RTSP servers over UDP
instead of TCP.  The syntax is the same as rtsp.</p>
</dd>
</li>
<dt><strong><a name="item_rsync_3a"><strong>rsync</strong>:</a></strong>

<dd>
<p>Information about rsync is available from <a href="http://rsync.samba.org.">http://rsync.samba.org.</a>
<code>URI</code> objects belonging to the rsync scheme support the common,
generic and server methods.  In addition, they provide methods to
access the userinfo sub-components: $uri-&gt;user and $uri-&gt;password.</p>
</dd>
</li>
<dt><strong><a name="item_sip_3a"><strong>sip</strong>:</a></strong>

<dd>
<p>The <em>sip</em> URI specification is described in sections 19.1 and 25
of RFC 3261.  <code>URI</code> objects belonging to the sip scheme support the
common, generic, and server methods with the exception of path related
sub-components.  In addition, they provide two methods to get and set
<em>sip</em> parameters: $uri-&gt;params_form and $uri-&gt;params.</p>
</dd>
</li>
<dt><strong><a name="item_sips_3a"><strong>sips</strong>:</a></strong>

<dd>
<p>See <em>sip</em> scheme.  Its syntax is the same as sip, but the default
port is different.</p>
</dd>
</li>
<dt><strong><a name="item_snews_3a"><strong>snews</strong>:</a></strong>

<dd>
<p>See <em>news</em> scheme.  Its syntax is the same as news, but the default
port is different.</p>
</dd>
</li>
<dt><strong><a name="item_telnet_3a"><strong>telnet</strong>:</a></strong>

<dd>
<p>An old specification of the <em>telnet</em> URI scheme is found in RFC
1738. <code>URI</code> objects belonging to the telnet scheme support the
common, generic and server methods.</p>
</dd>
</li>
<dt><strong><a name="item_tn3270_3a"><strong>tn3270</strong>:</a></strong>

<dd>
<p>These URIs are used like <em>telnet</em> URIs but for connections to IBM
mainframes.  <code>URI</code> objects belonging to the tn3270 scheme support the
common, generic and server methods.</p>
</dd>
</li>
<dt><strong><a name="item_ssh_3a"><strong>ssh</strong>:</a></strong>

<dd>
<p>Information about ssh is available at <a href="http://www.openssh.com/.">http://www.openssh.com/.</a>
<code>URI</code> objects belonging to the ssh scheme support the common,
generic and server methods. In addition, they provide methods to
access the userinfo sub-components: $uri-&gt;user and $uri-&gt;password.</p>
</dd>
</li>
<dt><strong><a name="item_urn_3a"><strong>urn</strong>:</a></strong>

<dd>
<p>The syntax of Uniform Resource Names is specified in RFC 2141.  <code>URI</code>
objects belonging to the urn scheme provide the common methods, and also the
methods $uri-&gt;nid and $uri-&gt;nss, which return the Namespace Identifier
and the Namespace-Specific String respectively.</p>
</dd>
<dd>
<p>The Namespace Identifier basically works like the Scheme identifier of
URIs, and further divides the URN namespace.  Namespace Identifier
assignments are maintained at
&lt;http://www.iana.org/assignments/urn-namespaces&gt;.</p>
</dd>
<dd>
<p>Letter case is not significant for the Namespace Identifier.  It is
always returned in lower case by the $uri-&gt;nid method.  The $uri-&gt;_nid
method can be used if you want it in its original case.</p>
</dd>
</li>
<dt><strong><a name="item_urn_3aisbn_3a"><strong>urn</strong>:<strong>isbn</strong>:</a></strong>

<dd>
<p>The <a href="#item_urn_3aisbn_3a"><code>urn:isbn:</code></a> namespace contains International Standard Book
Numbers (ISBNs) and is described in RFC 3187.  A <code>URI</code> object belonging
to this namespace has the following extra methods (if the
Business::ISBN module is available): $uri-&gt;isbn,
$uri-&gt;isbn_publisher_code, $uri-&gt;isbn_country_code, $uri-&gt;isbn_as_ean.</p>
</dd>
</li>
<dt><strong><a name="item_urn_3aoid_3a"><strong>urn</strong>:<strong>oid</strong>:</a></strong>

<dd>
<p>The <a href="#item_urn_3aoid_3a"><code>urn:oid:</code></a> namespace contains Object Identifiers (OIDs) and is
described in RFC 3061.  An object identifier consists of sequences of digits
separated by dots.  A <code>URI</code> object belonging to this namespace has an
additional method called $uri-&gt;oid that can be used to get/set the oid
value.  In a list context, oid numbers are returned as separate elements.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="configuration_variables">CONFIGURATION VARIABLES</a></h1>
<p>The following configuration variables influence how the class and its
methods behave:</p>
<dl>
<dt><strong><a name="item__uri__abs_allow_relative_scheme">$URI::ABS_ALLOW_RELATIVE_SCHEME</a></strong>

<dd>
<p>Some older parsers used to allow the scheme name to be present in the
relative URL if it was the same as the base URL scheme.  RFC 2396 says
that this should be avoided, but you can enable this old behaviour by
setting the $URI::ABS_ALLOW_RELATIVE_SCHEME variable to a TRUE value.
The difference is demonstrated by the following examples:</p>
</dd>
<dd>
<pre>
  URI-&gt;new(&quot;<a href="http:foo&quot">http:foo&quot</a>;)-&gt;abs(&quot;<a href="http://host/a/b&quot">http://host/a/b&quot</a>;)
      ==&gt;  &quot;<a href="http:foo&quot">http:foo&quot</a>;</pre>
</dd>
<dd>
<pre>
  <span class="keyword">local</span> <span class="variable">$URI::ABS_ALLOW_RELATIVE_SCHEME</span> <span class="operator">=</span> <span class="number">1</span><span class="operator">;</span>
  <span class="variable">URI</span><span class="operator">-&gt;</span><span class="variable">new</span><span class="operator">(</span><span class="string">"http:foo"</span><span class="operator">)-&gt;</span><span class="keyword">abs</span><span class="operator">(</span><span class="string">"http://host/a/b"</span><span class="operator">)</span>
      <span class="operator">==&gt;</span>  <span class="string">"http:/host/a/foo"</span>
</pre>
</dd>
</li>
<dt><strong><a name="item__uri__abs_remote_leading_dots">$URI::ABS_REMOTE_LEADING_DOTS</a></strong>

<dd>
<p>You can also have the <a href="#item_abs"><code>abs()</code></a> method ignore excess &quot;..&quot;
segments in the relative URI by setting $URI::ABS_REMOTE_LEADING_DOTS
to a TRUE value.  The difference is demonstrated by the following
examples:</p>
</dd>
<dd>
<pre>
  URI-&gt;new(&quot;../../../foo&quot;)-&gt;abs(&quot;<a href="http://host/a/b&quot">http://host/a/b&quot</a>;)
      ==&gt; &quot;<a href="http://host/../../foo&quot">http://host/../../foo&quot</a>;</pre>
</dd>
<dd>
<pre>
  <span class="keyword">local</span> <span class="variable">$URI::ABS_REMOTE_LEADING_DOTS</span> <span class="operator">=</span> <span class="number">1</span><span class="operator">;</span>
  <span class="variable">URI</span><span class="operator">-&gt;</span><span class="variable">new</span><span class="operator">(</span><span class="string">"../../../foo"</span><span class="operator">)-&gt;</span><span class="keyword">abs</span><span class="operator">(</span><span class="string">"http://host/a/b"</span><span class="operator">)</span>
      <span class="operator">==&gt;</span> <span class="string">"http://host/foo"</span>
</pre>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="bugs">BUGS</a></h1>
<p>Using regexp variables like $1 directly as arguments to the URI methods
does not work too well with current perl implementations.  I would argue
that this is actually a bug in perl.  The workaround is to quote
them. Example:</p>
<pre>
   <span class="regex">/(...)/</span> <span class="operator">||</span> <span class="keyword">die</span><span class="operator">;</span>
   <span class="variable">$u</span><span class="operator">-&gt;</span><span class="variable">query</span><span class="operator">(</span><span class="string">"$1"</span><span class="operator">);</span>
</pre>
<p>
</p>
<hr />
<h1><a name="parsing_uris_with_regexp">PARSING URIs WITH REGEXP</a></h1>
<p>As an alternative to this module, the following (official) regular
expression can be used to decode a URI:</p>
<pre>
  <span class="keyword">my</span><span class="operator">(</span><span class="variable">$scheme</span><span class="operator">,</span> <span class="variable">$authority</span><span class="operator">,</span> <span class="variable">$path</span><span class="operator">,</span> <span class="variable">$query</span><span class="operator">,</span> <span class="variable">$fragment</span><span class="operator">)</span> <span class="operator">=</span>
  <span class="variable">$uri</span> <span class="operator">=~</span> <span class="regex">m|(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?|</span><span class="operator">;</span>
</pre>
<p>The <code>URI::Split</code> module provides the function <code>uri_split()</code> as a
readable alternative.</p>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><a href="../lib/URI/file.html">the URI::file manpage</a>, <a href="../lib/URI/WithBase.html">the URI::WithBase manpage</a>, <a href="../lib/URI/QueryParam.html">the URI::QueryParam manpage</a>, <a href="../lib/URI/Escape.html">the URI::Escape manpage</a>,
<a href="../lib/URI/Split.html">the URI::Split manpage</a>, <a href="../lib/URI/Heuristic.html">the URI::Heuristic manpage</a></p>
<p>RFC 2396: &quot;Uniform Resource Identifiers (URI): Generic Syntax&quot;,
Berners-Lee, Fielding, Masinter, August 1998.</p>
<p><a href="http://www.iana.org/assignments/uri-schemes">http://www.iana.org/assignments/uri-schemes</a></p>
<p><a href="http://www.iana.org/assignments/urn-namespaces">http://www.iana.org/assignments/urn-namespaces</a></p>
<p><a href="http://www.w3.org/Addressing/">http://www.w3.org/Addressing/</a></p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Copyright 1995-2003 Gisle Aas.</p>
<p>Copyright 1995 Martijn Koster.</p>
<p>This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.</p>
<p>
</p>
<hr />
<h1><a name="authors___acknowledgments">AUTHORS / ACKNOWLEDGMENTS</a></h1>
<p>This module is based on the <code>URI::URL</code> module, which in turn was
(distantly) based on the <code>wwwurl.pl</code> code in the libwww-perl for
perl4 developed by Roy Fielding, as part of the Arcadia project at the
University of California, Irvine, with contributions from Brooks
Cutter.</p>
<p><code>URI::URL</code> was developed by Gisle Aas, Tim Bunce, Roy Fielding and
Martijn Koster with input from other people on the libwww-perl mailing
list.</p>
<p><code>URI</code> and related subclasses was developed by Gisle Aas.</p>

</body>

</html>

⌨️ 快捷键说明

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