HTTP::XSHeaders - Fast XS Header library, replacing HTTP::Headers and HTTP::Headers::Fast.
# load once
# keep using HTTP::Headers or HTTP::Headers::Fast as you wish
This is a work in progress. Once we feel it is stable, the version will be bumped to 1.0. Until then, feel free to use and try and submit tickets, but do this at your own risk.
By loading HTTP::XSHeaders anywhere, you replace any usage of HTTP::Headers and HTTP::Headers::Fast with a fast C implementation.
You can continue to use HTTP::Headers and HTTP::Headers::Fast and any other module that depends on them just like you did before. It's just faster now.
Since version 0.400000 HTTP::XSHeaders is considered Thread-Safe.
First there was HTTP::Headers. It's good, stable, and ubiquitous. However, it's slow.
Along came HTTP::Headers::Fast. Gooder, stable, and used internally by Plack, so you know it means business.
Not fast enough, we implemented an XS version of it, released under the name HTTP::Headers::Fast::XS. It was a successful experiment. However, we thought we could do better.
HTTP::XSHeaders provides a complete rework of the headers library with the intent of being fast, lean, and clear. It does not attempt to implement the original algorithm, but instead uses its own C-level implementation with an interface that is mostly compatible with both HTTP::Headers and HTTP::Headers::Fast.
This module attempts to replace HTTP::Headers, HTTP::Headers::Fast, and the XS implementation of it, HTTP::Headers::Fast::XS. We attempt to continue developing this module and perhaps deprecate HTTP::Headers::Fast::XS.
While we keep compatibility with the interfaces of HTTP::Headers and HTTP::Headers::Fast, we've taken the liberty to make several changes that were deemed reasonable and sane:
Aligning in as_string method
as_string method does weird stuff in order to keep the original indentation. This is unnecessary and unhelpful. We simply add one space as indentation after the first newline.
Normalisation of header names
When a given header is one of the standard HTTP headers, we convert it to the standard casing; otherwise, we normalise it by:
Converting each underscore to a hyphen.
Converting the first letter of each word to uppercase.
Converting the rest of the letters of each word to lowercase.
Accept-Encoding => Accept-Encoding
www-authenticate => WWW-Authenticate (notice the weird standard case for WWW)
my_header => My-Header
Literal header names using leading colon are not supported
Following the previous item, we don't treat an initial colon character in any special way.
$TRANSLATE_UNDERSCORE is not supported
$TRANSLATE_UNDERSCORE (which controls whether underscores are translated or not) is not supported. It's barely documented (or isn't at all), it isn't used by anything on CPAN, nor can we find any use-case other than the tests. So, instead, we always convert underscores to dashes.
Storable is loaded but not used
Both HTTP::Headers and HTTP::Headers::Fast use Storable for cloning. While HTTP::Headers loads it automatically, HTTP::Headers::Fast loads it lazily.
Since we override both, we load Storable always. However, we do not use it for cloning and instead implemented our C-level struct cloning.
HTTP::Headers 6.05, HTTP::Headers::Fast 0.19, HTTP::XSHeaders 0.200000
These match the API described in HTTP::Headers and HTTP::Headers::Fast, with the caveats described under COMPATIBILITY.
Please see those modules for documentation on what these methods and attributes are.
Gonzalo Diethelm gonzus AT cpan DOT org
gonzus AT cpan DOT org
Sawyer X xsawyerx AT cpan DOT org
xsawyerx AT cpan DOT org
To install HTTP::XSHeaders, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.