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

📄 uri.pm

📁 稀饭伊人相册系统继承了新天堂多用户相册系统的功能
💻 PM
📖 第 1 页 / 共 2 页
字号:
This method returns the fragment identifier of a URI referenceas an escaped string.=item $uri->as_stringThis method returns a URI object to a plain string.  URI objects arealso converted to plain strings automatically by overloading.  Thismeans that $uri objects can be used as plain strings in most Perlconstructs.=item $uri->canonicalThis method will return a normalized version of the URI.  The rulesfor normalization are scheme dependent.  It usually involveslowercasing of the scheme and the Internet host name components,removing the explicit port specification if it matches the default port,uppercasing all escape sequences, and unescaping octets that can bebetter represented as plain characters.For efficiency reasons, if the $uri already was in normalized form,then a reference to it is returned instead of a copy.=item $uri->eq( $other_uri )=item URI::eq( $first_uri, $other_uri )This method tests whether two URI references are equal.  URI referencesthat normalize to the same string are considered equal.  The methodcan also be used as a plain function which can also test two stringarguments.If you need to test whether two C<URI> object references denote thesame object, use the '==' operator.=item $uri->abs( $base_uri )This method returns an absolute URI reference.  If $uri already isabsolute, then a reference to it is simply returned.  If the $uriis relative, then a new absolute URI is constructed by combining the$uri and the $base_uri, and returned.=item $uri->rel( $base_uri )This method returns a relative URI reference if it is possible tomake one that denotes the same resource relative to $base_uri.If not, then $uri is simply returned.=back=head1 GENERIC METHODSThe following methods are available to schemes that use thecommon/generic syntax for hierarchical namespaces.  The description ofschemes below will tell which one these are.  Unknown schemes areassumed to support the generic syntax, and therefore the followingmethods:=over 4=item $uri->authority( [$new_authority] )This method sets and returns the escaped authority componentof the $uri.=item $uri->path( [$new_path] )This method sets and returns the escaped path component ofthe $uri (the part between the host name and the query or fragment).The path will never be undefined, but it can be the empty string.=item $uri->path_query( [$new_path_query] )This method sets and returns the escaped path and querycomponents as a single entity.  The path and the query areseparated by a "?" character, but the query can itself contain "?".=item $uri->path_segments( [$segment,...] )This method sets and returns the path.  In scalar context it returnsthe same value as $uri->path.  In list context it will return theunescaped path segments that make up the path.  Path segments thathave parameters are returned as an anonymous array.  The first elementis the unescaped path segment proper.  Subsequent elements are escapedparameter strings.  Such an anonymous array uses overloading so it canbe treated as a string too, but this string does not include theparameters.=item $uri->query( [$new_query] )This method sets and returns the escaped query component ofthe $uri.=item $uri->query_form( [$key => $value,...] )This method sets and returns query components that use theI<application/x-www-form-urlencoded> format.  Key/value pairs areseparated by "&" and the key is separated from the value with a "="character.=item $uri->query_keywords( [$keywords,...] )This method sets and returns query components that use thekeywords separated by "+" format.=back=head1 SERVER METHODSSchemes where the I<authority> component denotes a Internet host willhave the following methods available in addition to the genericmethods.=over 4=item $uri->userinfo( [$new_userinfo] )This method sets and returns the escaped userinfo part of theauthority componenent.For some schemes this will be a user name and a password separated bya colon.  This practice is not recommended. Embedding passwords inclear text (such as URI) has proven to be a security risk in almostevery case where it has been used.=item $uri->host( [$new_host] )This method sets and returns the unescaped hostname.If the $new_host string ends with a colon and a number, then thisnumber will also set the port.=item $uri->port( [ $new_port] )This method sets and returns the port.  The port is simple integerthat should be greater than 0.If no explicit port is specified in the URI, then the default port ofthe URI scheme is returned. If you don't want the default portsubstituted, then you can use the $uri->_port method instead.=item $uri->host_port( [ $new_host_port ] )This method sets and returns the host and port as a singleunit.  The returned value will include a port, even if it matches thedefault port.  The host part and the port part is separated with acolon; ":".=item $uri->default_portThis method returns the default port of the URI scheme that $uribelongs to.  For I<http> this will be the number 80, for I<ftp> thiswill be the number 21, etc.  The default port for a scheme can not bechanged.=back=head1 SCHEME SPECIFIC SUPPORTThe following URI schemes are specifically supported.  For C<URI>objects not belonging to one of these you can only use the common andgeneric methods.=over 4=item B<data>:The I<data> URI scheme is specified in RFC 2397.  It allows inclusionof small data items as "immediate" data, as if it had been includedexternally.C<URI> objects belonging to the data scheme support the common methodsand two new methods to access their scheme specific components;$uri->media_type and $uri->data.  See L<URI::data> for details.=item B<file>:An old specification of the I<file> URI scheme is found in RFC 1738.A new RFC 2396 based specification in not available yet, but file URIreferences are in common use.C<URI> objects belonging to the file scheme support the common andgeneric methods.  In addition they provide two methods to map file URIback to local file names; $uri->file and $uri->dir.  See L<URI::file>for details.=item B<ftp>:An old specification of the I<ftp> URI scheme is found in RFC 1738.  Anew RFC 2396 based specification in not available yet, but ftp URIreferences are in common use.C<URI> objects belonging to the ftp scheme support the common,generic and server methods.  In addition they provide two methods toaccess the userinfo sub-components: $uri->user and $uri->password.=item B<gopher>:The I<gopher> URI scheme is specified in<draft-murali-url-gopher-1996-12-04> and will hopefully be availableas a RFC 2396 based specification.C<URI> objects belonging to the gopher scheme support the common,generic and server methods. In addition they support some methods toaccess gopher specific path components: $uri->gopher_type,$uri->selector, $uri->search, $uri->string.=item B<http>:The I<http> URI scheme is specified in RFC 2616.The scheme is used to reference resources hosted by HTTP servers.C<URI> objects belonging to the http scheme support the common,generic and server methods.=item B<https>:The I<https> URI scheme is a Netscape invention which is commonlyimplemented.  The scheme is used to reference HTTP servers through SSLconnections.  Its syntax is the same as http, but the defaultport is different.=item B<ldap>:The I<ldap> URI scheme is specified in RFC 2255.  LDAP is theLightweight Directory Access Protocol.  An ldap URI describes an LDAPsearch operation to perform to retrieve information from an LDAPdirectory.C<URI> objects belonging to the ldap scheme support the common,generic and server methods as well as specific ldap methods; $uri->dn,$uri->attributes, $uri->scope, $uri->filter, $uri->extensions.  SeeL<URI::ldap> for details.=item B<mailto>:The I<mailto> URI scheme is specified in RFC 2368.  The scheme wasoriginally used to designate the Internet mailing address of anindividual or service.  It has (in RFC 2368) been extended to allowsetting of other mail header fields and the message body.C<URI> objects belonging to the mailto scheme support the commonmethods and the generic query methods.  In addition they support thefollowing mailto specific methods: $uri->to, $uri->headers.=item B<news>:The I<news>, I<nntp> and I<snews> URI schemes are specified in<draft-gilman-news-url-01> and will hopefully be available as a RFC2396 based specification soon.C<URI> objects belonging to the news scheme support the common,generic and server methods.  In addition they provide some methods toaccess the path: $uri->group and $uri->message.=item B<nntp>:See I<news> scheme.=item B<pop>:The I<pop> URI scheme is specified in RFC 2384. The scheme is used toreference a POP3 mailbox.C<URI> objects belonging to the pop scheme support the common, genericand server methods.  In addition they provide two methods to access theuserinfo components: $uri->user and $uri->auth=item B<rlogin>:An old speficication of the I<rlogin> URI scheme is found in RFC1738. C<URI> objects belonging to the rlogin scheme support thecommon, generic and server methods.=item B<rtsp>:The I<rtsp> URL specification can be found in section 3.2 of RFC 2326.C<URI> objects belonging to the rtsp scheme support the common,generic, and server methods, with the exception of userinfo andquery-related sub-components.=item B<rtspu>:The I<rtspu> URI scheme is used to talk to RTSP servers over UDPinstead of TCP.  The syntax is the same as rtsp.=item B<rsync>:Information about rsync is available from http://rsync.samba.org.C<URI> objects belonging to the rsync scheme support the common,generic and server methods.  In addition they provide methods toaccess the userinfo sub-components: $uri->user and $uri->password.=item B<sip>:The I<sip> URI specification is described in sections 19.1 and 25of RFC 3261.  C<URI> objects belonging to the sip scheme support thecommon, generic, and server methods with the exception of path relatedsub-components.  In addition, they provide two methods to get and setI<sip> parameters, $uri->params_form and $uri->params.=item B<sips>:See I<sip> scheme.  Its syntax is the same as sip, but the defaultport is different.=item B<snews>:See I<news> scheme.  Its syntax is the same as news, but the defaultport is different.=item B<telnet>:An old speficication of the I<telnet> URI scheme is found in RFC1738. C<URI> objects belonging to the telnet scheme support thecommon, generic and server methods.=item B<ssh>:Information about ssh is available at http://www.openssh.com/.C<URI> objects belonging to the ssh scheme support the common,generic and server methods. In addition they provide methods toaccess the userinfo sub-components: $uri->user and $uri->password.=item B<urn>:The syntax of Uniform Resource Names is specified in RFC 2141.  C<URI>objects belonging to the urn scheme provide the common methods and themethods: $uri->nid and $uri->nss that returns the Namespace Identifierand the Namespace Specific String respectively.The Namespace Identifier basically works like the Scheme identifier ofURIs, and further divides the URN namespace.  Namespace Identifierassignments are maintained at<http://www.iana.org/assignments/urn-namespaces>.Letter case is not significant for the Namespace Identifier.  It isalways returned in lower case by the $uri->nid method.  The $uri->_nidmethod can be used if you want it in its original case.=item B<urn>:B<isbn>:The C<urn:isbn:> namespace contains International Standard BookNumbers (ISBNs) and is described in RFC 3187.  C<URI> object belongingto this namespace has the following extra methods (if theBusiness::ISBN module is available); $uri->isbn,$uri->isbn_publisher_code, $uri->isbn_country_code, $uri->isbn_as_ean.=item B<urn>:B<oid>:The C<urn:oid:> namespace contains Object Identifiers (OIDs) and isdescribed in RFC 3061.  An object identifier is sequences of digitsseparated by dots.  C<URI> object belonging to this namespace has anadditional method called $uri->oid that can be used to get/set the oidvalue.  In list context oid numbers are returned as separate elements.=back=head1 CONFIGURATION VARIABLESThe following configuration variables influence how the class and itsmethods behave:=over 4=item $URI::ABS_ALLOW_RELATIVE_SCHEMESome older parsers used to allow the scheme name to be present in therelative URL if it was the same as the base URL scheme.  RFC 2396 saysthat this should be avoided, but you can enable this old behaviour bysetting the $URI::ABS_ALLOW_RELATIVE_SCHEME variable to a TRUE value.The difference is demonstrated by the following examples:  URI->new("http:foo")->abs("http://host/a/b")      ==>  "http:foo"  local $URI::ABS_ALLOW_RELATIVE_SCHEME = 1;  URI->new("http:foo")->abs("http://host/a/b")      ==>  "http:/host/a/foo"=item $URI::ABS_REMOTE_LEADING_DOTSYou can also have the abs() method ignore excess ".."segments in the relative URI by setting $URI::ABS_REMOTE_LEADING_DOTSto a TRUE value.  The difference is demonstrated by the followingexamples:  URI->new("../../../foo")->abs("http://host/a/b")      ==> "http://host/../../foo"  local $URI::ABS_REMOTE_LEADING_DOTS = 1;  URI->new("../../../foo")->abs("http://host/a/b")      ==> "http://host/foo"=back=head1 BUGSUsing regexp variables like $1 directly as argument to the URI methodsdo not work too well with current perl implementations.  I would arguethat this is actually a bug in perl.  The workaround is to quotethem. E.g.:   /(...)/ || die;   $u->query("$1");=head1 PARSING URIs WITH REGEXPAs an alternative to this module, the following (official) regularexpression can be used to decode a URI:  my($scheme, $authority, $path, $query, $fragment) =  $uri =~ m|^(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?|;=head1 SEE ALSOL<URI::file>, L<URI::WithBase>, L<URI::Escape>, L<URI::Heuristic>RFC 2396: "Uniform Resource Identifiers (URI): Generic Syntax",Berners-Lee, Fielding, Masinter, August 1998.http://www.iana.org/assignments/uri-schemeshttp://www.iana.org/assignments/urn-namespaceshttp://www.w3.org/Addressing/=head1 COPYRIGHTCopyright 1995-2002 Gisle Aas.Copyright 1995 Martijn Koster.This program is free software; you can redistribute it and/or modifyit under the same terms as Perl itself.=head1 AUTHORS / ACKNOWLEDGMENTSThis module is based on the C<URI::URL> module, which in turn was(distantly) based on the C<wwwurl.pl> code in the libwww-perl forperl4 developed by Roy Fielding, as part of the Arcadia project at theUniversity of California, Irvine, with contributions from BrooksCutter.C<URI::URL> was developed by Gisle Aas, Tim Bunce, Roy Fielding andMartijn Koster with input from other people on the libwww-perl mailinglist.C<URI> and related subclasses was developed by Gisle Aas.=cut

⌨️ 快捷键说明

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