The manakai project

Web::Origin

Origin API

SYNOPSIS

  use Web::Origin;
  $origin = Web::Origin->new_tuple ($host, $domain, $port);
  $origin = Web::Origin->new_opaque;
  warn $origin->is_opaque;
  warn $origin->to_ascii;
  warn $origin->to_unicode;
  warn $origin->same_origin_as ($origin2);

SYNOPSIS

The Web::Origin object represents an origin.

METHODS

There are following methods:

$origin = Web::Origin->new_tuple ($scheme, $host, $port)

Return a tuple origin.

The first argument must be a canonicalized (i.e. lowercase) URL scheme.

The second argument must be a canonicalized host (i.e. domain, IPv4 address, or IPv6 address) string.

The third argument must be a port number or undef.

$origin = Web::Origin->new_opaque

Return an opaque origin.

$boolean = $origin->is_opaque

Return whether the origin is an opaque origin (true) or tuple origin (false).

$origin->set_domain ($host)

Set the domain of the origin. The origin must be a tuple origin. The argument must be a host (Web::Host) that is a domain.

$boolean = $origin1->same_origin_as ($origin2)

Return whether two origins are same origin or not.

$boolean = $origin1->same_origin_domain_as ($origin2)

Return whether two origins are same origin-domain or not.

$string = $origin->to_ascii

Return the ASCII serialization of the origin.

$string = $origin->to_unicode

Return the Unicode serialization of the origin.

SEE ALSO

Web::URL has a method to create an origin object from a URL.

SPECIFICATION

HTML Standard <https://html.spec.whatwg.org/#origin>.

AUTHOR

Wakaba <wakaba@suikawiki.org>.

LICENSE

Copyright 2016 Wakaba <wakaba@suikawiki.org>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.