HTTP::Promise::Headers::Generic - Generic HTTP Header Class
package HTTP::Promise::Header::MyHeader; use strict; use warnings; use parent qw( HTTP::Promise::Headers::Generic );
v0.1.0
This is a generic module to be inherited by HTTP header modules. See for example: HTTP::Promise::Headers::AcceptEncoding, HTTP::Promise::Headers::AcceptLanguage, HTTP::Promise::Headers::Accept, HTTP::Promise::Headers::AltSvc, HTTP::Promise::Headers::CacheControl, HTTP::Promise::Headers::ClearSiteData, HTTP::Promise::Headers::ContentDisposition, HTTP::Promise::Headers::ContentRange, HTTP::Promise::Headers::ContentSecurityPolicy, HTTP::Promise::Headers::ContentSecurityPolicyReportOnly, HTTP::Promise::Headers::ContentType, HTTP::Promise::Headers::Cookie, HTTP::Promise::Headers::ExpectCT, HTTP::Promise::Headers::Forwarded, HTTP::Promise::Headers::Generic, HTTP::Promise::Headers::KeepAlive, HTTP::Promise::Headers::Link, HTTP::Promise::Headers::Range, HTTP::Promise::Headers::ServerTiming, HTTP::Promise::Headers::StrictTransportSecurity, HTTP::Promise::Headers::TE
Return a string representation of this header field object.
Sets or gets the object headers field name
Provided with some string and this returns the URI-escaped version of this using URI::Escape::XS
By default and superseded by inheriting classes such as Content-Type that has more elaborate value with parameters
Provided with a filename, and this will decode it, if necessary, by calling "decode_filename" in HTTP::Promise::Headers
It returns in list context the decoded filename, the character-set and language used and in scalar context the decoded filename.
If the filename did not need to be decoded, it will return the filename untouched, so this is quite safe to use.
See rfc2231
Provided with a filename, and an optional language, and this will encode it, if necessary, following the rfc2231
If the filename did not need to be encoded, it returns undef, so be sure to check for the return value.
undef
Sets or gets the header value object
Returns the header value object as a string, if a header value object is set, or an empty string otherwise.
This instantiates a new header value object, passing it whatever arguments were provided, and return the new object.
Returns a new boundary using Data::UUID
Does the same thing as "_get_header_value_object"
This instantiates a new quality value object using HTTP::Promise::Field::QualityValue, passing it whatever arguments were provided, and return the new object.
HTTP::Promise::Field::QualityValue
Provided with a string, and this instantiates a new header value object, by calling "new_from_header" in Module::Generic::HeaderValue passing it the string and any other arguments that were provided, and return the new object.
Upon error, this sets an error and returns undef
Provided with a string representing a quality value, and this will parse it and return a new array object
See rfc7231, section 5.3.1
Provided with a list of strings and this will ensure any special characters are escaped before returning them as one string separated by comma.
See also "_qstring_split"
Provided with a string, and this will split it by comma, mindful of any special characters.
It returns an array of the parts split.
Provided with an element and its value, and this will instantiate a new HTTP::Promise::Field::QualityValue object and add it to the list of objects contained with the method elements (implemented in each specific header module)
elements
This takes the list of all elements contained with the method elements (implemented in each specific header module) and returns them as a string separated by comma.
Sets or gets the array object containing the list of quality values.
Provided with a quality value element, and this returns its corresponding object if it exists, or an empty string otherwise.
Provided with a string, and this returns an array object of matching quality value objects in their order of preference.
This method is used to do the actual work of matching a requested value such as fr-FR or <text/html> depending on the type of header, against the ones announced in the header.
fr-FR
For example:
Accept: image/* Accept: text/html Accept: */* Accept: text/html, application/xhtml+xml, application/xml;q=0.9, image/webp, */*;q=0.8 Accept-Encoding: gzip Accept-Encoding: deflate, gzip;q=1.0, *;q=0.5 Accept-Language: fr-FR, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5
This takes an "acceptable" scalar object, an array object of proposed quality-value objects, and an array object of original proposed value, and possibly an hash reference of already seen object address.
It returns an array object of matching quality-value objects.
Provided with a quality-value string or object, and this will remove it from the list of elements.
It returns the element removed, or upon error, this sets an error and returns undef
This takes an optional hash or hash reference of options and returns an array object of sorted element by their quality-value.
Supported options are:
asc
Boolean. If true, the elements will be sorted in their ascending order, otherwise in their descending order.
In retrieval mode, this takes a header value parameter, and this returns its value.
In assignment mode, this takes a header value parameter, and a value, possibly undef and assign it to the given parameter.
In retrieval mode, this takes a header value parameter, and it returns its corresponding value.
In assignment mode, this takes a header value parameter, and a value and assign it.
This takes a list of header-value parameter and their corresponding value and set them.
If no argument is provided, this returns the array object containing all the header-value parameters.
This takes an hash or hash reference of options and returns the header-value parameters as a regular string.
equal
separator or sep
separator
sep
This sets or gets a boolean value for the given header-value property.
It returns the boolean value for the given property.
This sets or gets a number for the given header-value property.
It returns the number value for the given property.
This sets or gets a value for the given header-value property.
It returns the value for the given property.
Sets or gets a quality-value parameter. If a value is provided, any double quote found at the bginning or end are removed.
It returns the current value.
This sets or gets a header main value.
For example text/html in text/html; charset=utf-8
text/html
text/html; charset=utf-8
Jacques Deguest <jack@deguest.jp>
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.
To install HTTP::Promise, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTTP::Promise
CPAN shell
perl -MCPAN -e shell install HTTP::Promise
For more information on module installation, please visit the detailed CPAN module installation guide.