« lib/HTTP/Promise/Headers/ContentSecurityPolicy.pm
↑ Summary
lib/HTTP/Promise/Headers/AcceptLanguage.pm »
| 1 | ##---------------------------------------------------------------------------- | ||||||||||
| 2 | ## Asynchronous HTTP Request and Promise - ~/lib/HTTP/Promise/Headers/AcceptEncoding.pm | ||||||||||
| 3 | ## Version v0.1.0 | ||||||||||
| 4 | ## Copyright(c) 2022 DEGUEST Pte. Ltd. | ||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||
| 6 | ## Created 2022/05/06 | ||||||||||
| 7 | ## Modified 2022/05/06 | ||||||||||
| 8 | ## All rights reserved. | ||||||||||
| 9 | ## | ||||||||||
| 10 | ## | ||||||||||
| 11 | ## This program is free software; you can redistribute it and/or modify it | ||||||||||
| 12 | ## under the same terms as Perl itself. | ||||||||||
| 13 | ##---------------------------------------------------------------------------- | ||||||||||
| 14 | package HTTP::Promise::Headers::AcceptEncoding; | ||||||||||
| 15 | BEGIN | ||||||||||
| 16 | { | ||||||||||
| 17 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 3 | ▶ | warnings::register_categories( 'HTTP::Promise' ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 3 | ▶ | use parent qw( HTTP::Promise::Headers::Accept ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 3 | our $VERSION = 'v0.1.0'; | |||||||||
| 22 | }; | ||||||||||
| 23 | |||||||||||
| 24 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | |||||||||||
| 27 | sub init | ||||||||||
| 28 | { | ||||||||||
| 29 | 4 | ▶ | my $self = shift( @_ ); | ||||||||
|
Subroutine
init: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 30 | 4 | ▶ | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 4 | $self->_field_name( 'Accept-Encoding' ); | |||||||||
| 32 | 4 | return( $self ); | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 3 | 1; | |||||||||
| 36 | # NOTE: POD | ||||||||||
| 37 | __END__ | ||||||||||
| 38 | |||||||||||
| 39 | =encoding utf-8 | ||||||||||
| 40 | |||||||||||
| 41 | =head1 NAME | ||||||||||
| 42 | |||||||||||
| 43 | HTTP::Promise::Headers::AcceptEncoding - Accept Encoding Header Field | ||||||||||
| 44 | |||||||||||
| 45 | =head1 SYNOPSIS | ||||||||||
| 46 | |||||||||||
| 47 | use HTTP::Promise::Headers::AcceptEncoding; | ||||||||||
| 48 | my $ac = HTTP::Promise::Headers::AcceptEncoding->new || | ||||||||||
| 49 | die( HTTP::Promise::Headers::AcceptEncoding->error, "\n" ); | ||||||||||
| 50 | my $ac = HTTP::Promise::Headers::AcceptEncoding->new( 'deflate, gzip;q=1.0, *;q=0.5' ) || | ||||||||||
| 51 | die( HTTP::Promise::Headers::AcceptEncoding->error, "\n" ); | ||||||||||
| 52 | $ac->add( 'br' ); | ||||||||||
| 53 | $ac->add( 'gzip' => 0.7 ); | ||||||||||
| 54 | $h->accept( $ac->as_string ); Accept: br, gzip;q=0.7 | ||||||||||
| 55 | # or | ||||||||||
| 56 | $h->accept( "$ac" ); | ||||||||||
| 57 | my $qv_elements = $ac->elements; | ||||||||||
| 58 | my $obj = $ac->get( 'br' ); | ||||||||||
| 59 | # change the weight | ||||||||||
| 60 | $obj->value( 0.3 ); | ||||||||||
| 61 | $ac->remove( 'br' ); | ||||||||||
| 62 | my $sorted_objects = $ac->sort; | ||||||||||
| 63 | my $asc_sorted = $ac->sort(1); | ||||||||||
| 64 | # Returns a Module::Generic::Array object | ||||||||||
| 65 | my $ok = $ac->match( [qw( br gzip )] ); | ||||||||||
| 66 | |||||||||||
| 67 | =head1 VERSION | ||||||||||
| 68 | |||||||||||
| 69 | v0.1.0 | ||||||||||
| 70 | |||||||||||
| 71 | =head1 DESCRIPTION | ||||||||||
| 72 | |||||||||||
| 73 | This class inherits all its features and methods from L<HTTP::Promise::Headers::Accept> | ||||||||||
| 74 | |||||||||||
| 75 | The following description is taken from Mozilla documentation. | ||||||||||
| 76 | |||||||||||
| 77 | Accept-Encoding: gzip | ||||||||||
| 78 | Accept-Encoding: compress | ||||||||||
| 79 | Accept-Encoding: deflate | ||||||||||
| 80 | Accept-Encoding: br | ||||||||||
| 81 | Accept-Encoding: identity | ||||||||||
| 82 | Accept-Encoding: * | ||||||||||
| 83 | |||||||||||
| 84 | // Multiple algorithms, weighted with the quality value syntax: | ||||||||||
| 85 | Accept-Encoding: deflate, gzip;q=1.0, *;q=0.5 | ||||||||||
| 86 | Accept-Encoding: br;q=1.0, gzip;q=0.8, *;q=0.1 | ||||||||||
| 87 | Accept-Encoding: gzip, compress, br | ||||||||||
| 88 | |||||||||||
| 89 | =head1 METHODS | ||||||||||
| 90 | |||||||||||
| 91 | See L<HTTP::Promise::Headers::Accept> | ||||||||||
| 92 | |||||||||||
| 93 | =head1 THREAD-SAFETY | ||||||||||
| 94 | |||||||||||
| 95 | This module is thread-safe for all operations, as it operates on per-object state and uses thread-safe external libraries. | ||||||||||
| 96 | |||||||||||
| 97 | =head1 AUTHOR | ||||||||||
| 98 | |||||||||||
| 99 | Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> | ||||||||||
| 100 | |||||||||||
| 101 | =head1 SEE ALSO | ||||||||||
| 102 | |||||||||||
| 103 | L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding> | ||||||||||
| 104 | |||||||||||
| 105 | L<HTTP::Promise>, L<HTTP::Promise::Request>, L<HTTP::Promise::Response>, L<HTTP::Promise::Message>, L<HTTP::Promise::Entity>, L<HTTP::Promise::Headers>, L<HTTP::Promise::Body>, L<HTTP::Promise::Body::Form>, L<HTTP::Promise::Body::Form::Data>, L<HTTP::Promise::Body::Form::Field>, L<HTTP::Promise::Status>, L<HTTP::Promise::MIME>, L<HTTP::Promise::Parser>, L<HTTP::Promise::IO>, L<HTTP::Promise::Stream>, L<HTTP::Promise::Exception> | ||||||||||
| 106 | |||||||||||
| 107 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 108 | |||||||||||
| 109 | Copyright(c) 2022 DEGUEST Pte. Ltd. | ||||||||||
| 110 | |||||||||||
| 111 | All rights reserved. | ||||||||||
| 112 | |||||||||||
| 113 | This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||
| 114 | |||||||||||
| 115 | =cut | ||||||||||