DESCRIPTION

URI::Fast is a faster alternative to URI. It is written in C and provides basic parsing and modification of a URI.

URI is an excellent module; it is battle-tested, robust, and handles many edge cases. As a result, it is rather slower than it would otherwise be for more trivial cases, such as inspecting the path or updating a single query parameter.

EXPORTED SUBROUTINES

uri

iri

Similar to "uri", but returns a URI::Fast::IRI object. A URI::Fast::IRI differs from a URI::Fast in that UTF-8 characters are permitted and will not be percent-encoded when modified.

uri_split

Behaves (hopefully) identically to URI::Split, but roughly twice as fast.

ATTRIBUTES

Unless otherwise specified, all attributes serve as full accessors, allowing the URI segment to be both retrieved and modified.

Each attribute further has a matching clearer method (clear_*) which unsets its value.

scheme

Gets or sets the scheme portion of the URI (e.g. http), excluding ://.

auth

The authorization section is composed of the username, password, host name, and port number:

hostname.com
someone@hostname.com
someone:secret@hostname.com:1234

Setting this field may be done with a string (see the note below about "ENCODING") or a hash reference of individual field names (usr, pwd, host, and port). In both cases, the existing values are completely replaced by the new values and any values not present are deleted.

usr

The username segment of the authorization string. Updating this value alters "auth".

pwd

The password segment of the authorization string. Updating this value alters "auth".

host

The host name segment of the authorization string. May be a domain string or an IP address. Updating this value alters "auth".

port

The port number segment of the authorization string. Updating this value alters "auth".

path

In scalar context, returns the entire path string. In list context, returns a list of path segments, split by /.

The path may also be updated using either a string or an array ref of segments:

$uri->path('/foo/bar');
$uri->path(['foo', 'bar']);

query

In scalar context, returns the complete query string, excluding the leading ?. The query string may be set in several ways.

query_keys

Does a fast scan of the query string and returns a list of unique parameter names that appear in the query string.

query_hash

Scans the query string and returns a hash ref of key/value pairs. Values are returned as an array ref, as keys may appear multiple times.

param

Gets or sets a parameter value. Setting a parameter value will replace existing values completely; the "query" string will also be updated. Setting a parameter to undef deletes the parameter from the URI.

frag

The fragment section of the URI, excluding the leading #.

ENCODING

URI::Fast tries to do the right thing in most cases with regard to reserved and non-ASCII characters. URI::Fast will fully encode reserved and non-ASCII characters when setting individual values. However, the "right thing" is a bit ambiguous when it comes to setting compound fields like "auth", "path", and "query".

When setting these fields with a string value, reserved characters are expected to be present, and are therefore accepted as-is. However, any non-ASCII characters will be percent-encoded (since they are unambiguous and there is no risk of double-encoding them).

The same goes for return values. For compound fields returning a string, non-ASCII characters are decoded but reserved characters are not. When returning a list or reference of the deconstructed field, individual values are decoded of both reserved and non-ASCII characters.

As a valued partner and proud supporter of MetaCPAN, StickerYou is
happy to offer a 10% discount on all Custom Stickers,
Business Labels, Roll Labels,
Vinyl Lettering or Custom Decals. StickerYou.com
is your one-stop shop to make your business stick.
Use code METACPAN10 at checkout to apply your discount.