HTTP::Promise::Headers::Link - Link Header Field


    use HTTP::Promise::Headers::Link;
    my $link = HTTP::Promise::Headers::Link->new || 
        die( HTTP::Promise::Headers::Link->error, "\n" );
    my $uri = $link->link;
    $link->link( '' );
    $link->rel( 'preconnect' );
    $h->link( "$link" );
    # Link: <>; rel="preconnect"
    $link->title( 'Foo' );
    $link->anchor( '#bar' );
    $cd->params( rel => 'preconnect', anchor => 'bar' );




The following is an extract from Mozilla documentation.

The HTTP Link entity-header field provides a means for serializing one or more links in HTTP headers. It is semantically equivalent to the HTML link element.


    Link: <>; rel="preconnect"; title="Foo"; anchor="#bar"



Sets or gets the anchor property.


Returns a string representation of the Link object.


Sets or gets the relationship of the Link as a scalar.

Sets or gets an URI. It returns the URI value (not an object).

When you set this value, it will be automatically surrounded by <>


Sets or gets an arbitrary Link property.

Note that if you use this, you bypass other specialised method who do some additional processing, so be mindful.


Sets or gets multiple arbitrary Link properties at once.

If called without any arguments, this returns the hash object used to store the Link properties.


Without any argument, this returns the string containing the original title of the link. The title is always optional.

If the property title* is set instead, then it will be decoded and used instead, and the value for "title_charset" and "title_lang" will be set.

When setting the title value, this takes an optional language iso 639 code (see rfc5987 and rfc2231). If the title contains non ascii characters, it will be automatically encoded according to rfc5987. and the property title* set instead. That property, by rfc standard, takes precedence over the title one.

See rfc8288, section 3 for more information.

The language provided, if any, will be used then.

For example:

    $h->link( '' );
    $h->rel( 'preconnect' );
    $h->title( q{Foo} );
    say "$h";
    # <>; rel="preconnect"; title="Foo"

    $h->link( '' );
    $h->rel( 'previous' );
    $h->title( q{「お早う」小津安二郎} );
    say "$h";
    #; rel="previous"; title*="UTF-8''%E3%81%8A%E6%97%A9%E3%81%86%E3%80%8D%E5%B0%8F%E6%B4%A5%E5%AE%89%E4%BA%8C%E9%83%8E"
    $h->link( '' );
    $h->rel( 'previous' );
    $h->title( q{「お早う」小津安二郎}, 'ja-JP' );
    say "$h";
    #; rel="previous"; title*="UTF-8'ja-JP'%E3%81%8A%E6%97%A9%E3%81%86%E3%80%8D%E5%B0%8F%E6%B4%A5%E5%AE%89%E4%BA%8C%E9%83%8E"

    # Using default value
    $h->title_lang( 'ja-JP' );
    $h->link( '' );
    $h->rel( 'previous' );
    $h->title( q{「お早う」小津安二郎}, 'ja-JP' );
    say "$h";
    #; rel="previous"; title*="UTF-8'ja-JP'%E3%81%8A%E6%97%A9%E3%81%86%E3%80%8D%E5%B0%8F%E6%B4%A5%E5%AE%89%E4%BA%8C%E9%83%8E"

    $headers->header( Link => "$h" );

The Link header value would then contain a property title* (with the trailing wildcard).


Sets or gets the encoded title charset.

This is used when the title contains non-ascii characters, such as Japanese, Korean, or Cyrillic. Although theoretically one can set any character set, by design this only accepts UTF-8 (case insensitive).

This is set automatically when calling "title". You actually need to call "title" first to have a value set.

Returns a scalar object containing the title charset.


Sets or gets the encoded title language. This takes an iso 639 language code (see rfc1766).

This is set automatically when calling "title". You actually need to call "title" first to have a value set.

Returns a scalar object containing the title language.


Jacques Deguest <>


See also rfc8288, section 3 and Mozilla documentation

HTTP::Promise, HTTP::Promise::Request, HTTP::Promise::Response, HTTP::Promise::Message, HTTP::Promise::Entity, HTTP::Promise::Headers, HTTP::Promise::Body, HTTP::Promise::Body::Form, HTTP::Promise::Body::Form::Data, HTTP::Promise::Body::Form::Field, HTTP::Promise::Status, HTTP::Promise::MIME, HTTP::Promise::Parser, HTTP::Promise::IO, HTTP::Promise::Stream, HTTP::Promise::Exception


Copyright(c) 2022 DEGUEST Pte. Ltd.

All rights reserved.

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