Search...TPTiny(3pm)
β¨ NAME β¨
Search::Elasticsearch::Cxn::HTTPTiny β bestie, it's a Cxn implementation that rides on HTTP::Tiny. That's the whole vibe. π
This is a page from the User Contributed Perl Documentation, and it's giving very "let me explain my whole personality in one line."
πΈ VERSION πΈ
version 8.12 π
π¦ DESCRIPTION π¦
So this class is the default HTTP Cxn class, and it's built on top of HTTP::Tiny. No cap. β¨
The HTTP::Tiny backend? Fast. It uses pure Perl, it supports proxies and https, and it does persistent connections. It's giving low-maintenance-but-high-performance, honestly iconic. π
This class does Search::Elasticsearch::Role::Cxn β go read that doc for more deets, it's the real main character β and it also does Search::Elasticsearch::Role::Is_Sync.
π CONFIGURATION π
π Inherited configuration π
Everything below comes from Search::Elasticsearch::Role::Cxn:
nodemax_content_lengthdeflatedeflaterequest_timeoutping_timeoutdead_timeoutmax_dead_timeoutsniff_request_timeoutsniff_timeouthandle_argshandle_args
Not me noticingdeflateandhandle_argsare each listed twice π that's exactly what the original says, so that's exactly what I'm giving you. Fidelity is the moment. π«Ά
π SSL/TLS π
Search::Elasticsearch::Cxn::HTTPTiny uses IO::Socket::SSL to do HTTPS. And here's the tea: by default, no validation of the remote host is performed. Like, it's not checking anything. π
You can change that by passing the ssl_options parameter, filled with any options that IO::Socket::SSL accepts. Say you wanna check the remote host actually has a trusted certificate and dodge man-in-the-middle attacks? You'd do:
use Search::Elasticsearch;
use IO::Socket::SSL;
my $es = Search::Elasticsearch->new(
nodes => [
"https://node1.mydomain.com:9200",
"https://node2.mydomain.com:9200",
],
ssl_options => {
SSL_verify_mode => SSL_VERIFY_PEER,
SSL_ca_file => '/path/to/cacert.pem'
}
);
And if the remote server can't be verified? An Search::Elasticsearch::Error will be thrown. Periodt.
Now if you want your client to show up with its own certificate β presenting itself to the remote server, main character energy β then you use:
use Search::Elasticsearch;
use IO::Socket::SSL;
my $es = Search::Elasticsearch->new(
nodes => [
"https://node1.mydomain.com:9200",
"https://node2.mydomain.com:9200",
],
ssl_options => {
SSL_verify_mode => SSL_VERIFY_PEER,
SSL_use_cert => 1,
SSL_ca_file => '/path/to/cacert.pem',
SSL_cert_file => '/path/to/client.pem',
SSL_key_file => '/path/to/client.pem',
}
);
β METHODS β
π perform_request() π
($status,$body) = $self->perform_request({
# required
method => 'GET|HEAD|POST|PUT|DELETE',
path => '/path/of/request',
qs => \%query_string_params,
# optional
data => $body_as_string,
mime_type => 'application/json',
timeout => $timeout
});
It sends the request off to the associated Elasticsearch node and hands you back a $status code plus the decoded response $body. And if the request flopped? It throws an error. No gentle letdown, just an error. π
πΈ Inherited methods πΈ
These all come from Search::Elasticsearch::Role::Cxn:
scheme()is_https()userinfo()default_headers()max_content_length()build_uri()host()port()uri()is_dead()is_live()next_ping()ping_failures()mark_dead()mark_live()force_ping()pings_ok()sniff()process_response()
π SEE ALSO π
Search::Elasticsearch::Role::CxnSearch::Elasticsearch::Cxn::LWPSearch::Elasticsearch::Cxn::NetCurl
iykyk, go read them, they're all part of the same little friend group. π«Ά
π AUTHOR π
Enrico Zimuel <enrico.zimuel@elastic.co> β the icon who wrote this. π
π COPYRIGHT AND LICENSE π
This software is Copyright (c) 2024 by Elasticsearch BV.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
Okay bestie that's the whole page!! π This beauty is perl v5.38.2, dated 2024-02-04, and it lives in the User Contributed Perl Documentation section. Slay, go make some requests. π β¨π¦
π¦ where this page comes from
- debian trixie: libsearch-elasticsearch-perl 8.12-1 Β· Apache-2.0
- ubuntu noble: libsearch-elasticsearch-perl 8.12-1 Β· Apache-2.0
- ubuntu resolute: libsearch-elasticsearch-perl 8.12-1 Β· Apache-2.0
- ubuntu stonking: libsearch-elasticsearch-perl 8.12-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms