---
name: "Search::Elasticsearch::Cxn::HTTPTiny"
section: "3pm"
platform: "linux"
package: "libsearch-elasticsearch-perl"
version: "8.12-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Search::Elasticsearch::Cxn::HTTPTiny"
---

# Search::Elasticsearch::Cxn::HTTPTiny(3pm)

A Cxn implementation which uses HTTP::Tiny

## NAME

Search::Elasticsearch::Cxn::HTTPTiny - A Cxn implementation which uses HTTP::Tiny

## VERSION

version 8.12

## DESCRIPTION

Provides the default HTTP Cxn class and is based on HTTP::Tiny. The HTTP::Tiny backend is fast, uses pure Perl, support proxies and https and provides persistent connections.

This class does Search::Elasticsearch::Role::Cxn, whose documentation provides more information, and Search::Elasticsearch::Role::Is\_Sync.

## CONFIGURATION

### Inherited configuration

From Search::Elasticsearch::Role::Cxn

- •

  node

- •

  max\_content\_length

- •

  deflate

- •

  deflate

- •

  request\_timeout

- •

  ping\_timeout

- •

  dead\_timeout

- •

  max\_dead\_timeout

- •

  sniff\_request\_timeout

- •

  sniff\_timeout

- •

  handle\_args

- •

  handle\_args

## SSL/TLS

Search::Elasticsearch::Cxn::HTTPTiny uses IO::Socket::SSL to support HTTPS.  By default, no validation of the remote host is performed.

This behaviour can be changed by passing the `"ssl_options"` parameter with any options accepted by IO::Socket::SSL. For instance, to check that the remote host has a trusted certificate, and to avoid man-in-the-middle attacks, you could do the following:

```
    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'
        }
    );
```

If the remote server cannot be verified, an Search::Elasticsearch::Error will be thrown.

If you want your client to present its own certificate to the remote server, then 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
    });
```

Sends the request to the associated Elasticsearch node and returns a `$status` code and the decoded response `$body`, or throws an error if the request failed.

### Inherited methods

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::Cxn

- •

  Search::Elasticsearch::Cxn::LWP

- •

  Search::Elasticsearch::Cxn::NetCurl

## AUTHOR

Enrico Zimuel \<enrico.zimuel@elastic.co\>

## 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
```
