HTTP-Promise

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

        The url of the proxy to use for the HTTP requests.

    *   "requests_redirectable"

        Array reference. This sets the list of http methods that are allowed
        to be redirected. Default to empty, which means that all methods can
        be redirected.

    *   "serialiser"

        String. Specify the serialiser to use for Promise::Me. Possible
        values are: cbor, sereal or storable

        By default it uses the value set in the global variable $SERIALISER,
        which is a copy of the $SERIALISER in Promise::Me, which should be
        by default "storable"

    *   "shared_mem_size"

        Integer. This will be passed on to Promise::Me. See Promise::Me for
        more details.

        It defaults to $Promise::Me::RESULT_MEMORY_SIZE

    *   "ssl_opts"

        Hash reference. Sets an hash reference of ssl options. The default
        values are set as follows:

        1. "verify_hostname"
                When enabled, this ensures it connects to servers that have
                a valid certificate matching the expected hostname.

                1.1. If environment variable "PERL_LWP_SSL_VERIFY_HOSTNAME"
                is set, the ssl option property "verify_hostname" takes its
                value.
                1.2. If environment variable "HTTPS_CA_FILE" or
                "HTTPS_CA_DIR" are set to a true value, then the ssl option
                property "verify_hostname" is set to 0 and option property
                "SSL_verify_mode" is set to 1
                1.3 If none of the above applies, it defaults
                "verify_hostname" to 1

        2. "SSL_ca_file"
                This is the path to a file containing the Certificate
                Authority certificates.

                If environment variable "PERL_LWP_SSL_CA_FILE" or
                "HTTPS_CA_FILE" is set, then the ssl option property
                "SSL_ca_file" takes its value.

        3. "SSL_ca_path"
                This is the path to a directory of files containing
                Certificate Authority certificates.

                If environment variable "PERL_LWP_SSL_CA_PATH" or
                "HTTPS_CA_DIR" is set, then the ssl option property
                "SSL_ca_path" takes its value.

        Other options can be set and are processed directly by the SSL
        Socket implementation in use. See IO::Socket::SSL or Net::SSL for
        details.

    *   "threshold"

        Integer. Sets the content length threshold beyond which, the
        response content will be stored to a locale file. It can then be
        fetch with "file". Default to global variable
        $CONTENT_SIZE_THRESHOLD, which is "undef" by default.

        See also the "max_size" option.

    *   "timeout"

        Integer. Sets the timeout value. Defaults to 180 seconds, i.e. 3
        minutes.

    *   "use_content_file"

        Boolean. Enables the use of a temporary local file to store the
        response content, no matter the size o the response content.

    *   "use_promise"

        Boolean. When true, this will have HTTP::Promise HTTP methods return
        a HTTP::Promise, and when false, it returns directly the
        HTTP::Promise::Response. Defaults to true.

METHODS
    The following methods are available. This interface provides similar
    interface as LWP::UserAgent while providing more granular control.

  accept_encoding
    String. Sets or gets whether we should accept compressed data.

    You can set it to "none" to disable it. By default, this is "auto", and
    it will set the "Accept-Encoding" "HTTP" header to all the supported
    encoding based on the availability of associated modules.

    You can also set this to a comma-separated list of known encoding,
    typically: "bzip2,deflate,gzip,rawdeflate,brotli"

    See HTTP::Promise::Stream for more details.

    Returns a scalar object of the current value.

  accept_language
    An array of acceptable language. This will be used to set the
    "Accept-Language" header.

    See also HTTP::Promise::Headers::AcceptLanguage

  agent
    This is a string.

    Sets or gets the agent id used to identify when making the server
    connection.

    It defaults to "HTTP-Promise/v0.1.0"

        my $p = HTTP::Promise->new( agent => 'MyBot/1.0' );

README  view on Meta::CPAN

    This method takes the same parameters as "request" and differs in that
    it will not try to handle redirects or authentication.

    It returns a promise object just like other methods.

    For example:

        use HTTP::Promise::Request;
        my $req = HTTP::Promise::Request->new( get => 'https://example.com' );
        my $p = HTTP::Promise->new;
        my $prom = $p->simple_request( $req )->then(sub
        {
            my( $resolve, $reject ) = @$_;
            # Get the HTTP::Promise::Response object
            my $resp = shift( @_ );
            # Do something with the response object
        })->catch(sub
        {
            # Get a HTTP::Promise::Exception object
            my $ex = shift( @_ );
            say "Got an error code ", $ex->code, " with message: ", $ex->message;
        });

    However, if "use_promise" is set to false, this will return an
    HTTP::Promise::Response object directly.

  ssl_opts
    Hash reference object. Sets or gets the ssl options properties used when
    making requests over ssl. The default values are set as follows:

    1. "verify_hostname"
            When enabled, this ensures it connects to servers that have a
            valid certificate matching the expected hostname.

            1.1. If environment variable "PERL_LWP_SSL_VERIFY_HOSTNAME" is
            set, the ssl option property "verify_hostname" takes its value.
            1.2. If environment variable "HTTPS_CA_FILE" or "HTTPS_CA_DIR"
            are set to a true value, then the ssl option property
            "verify_hostname" is set to 0 and option property
            "SSL_verify_mode" is set to 1
            1.3 If none of the above applies, it defaults "verify_hostname"
            to 1

    2. "SSL_ca_file"
            This is the path to a file containing the Certificate Authority
            certificates.

            If environment variable "PERL_LWP_SSL_CA_FILE" or
            "HTTPS_CA_FILE" is set, then the ssl option property
            "SSL_ca_file" takes its value.

    3. "SSL_ca_path"
            This is the path to a directory of files containing Certificate
            Authority certificates.

            If environment variable "PERL_LWP_SSL_CA_PATH" or "HTTPS_CA_DIR"
            is set, then the ssl option property "SSL_ca_path" takes its
            value.

    Other options can be set and are processed directly by the SSL Socket
    implementation in use. See IO::Socket::SSL or Net::SSL for details.

  stop_if
    Sets or gets a callback code reference (reference to a perl subroutine
    or an anonymous subroutine) that will be used to determine if we should
    keep trying upon reading data from the filehandle and an "EINTR" error
    occurs.

    If the callback returns true, further attempts will stop and return an
    error. The default is to continue trying.

  threshold
    Integer. Sets the content length threshold beyond which, the response
    content will be stored to a locale file. It can then be fetch with
    "file". Default to global variable $CONTENT_SIZE_THRESHOLD, which is
    "undef" by default.

    See also the "max_size" option.

        my $p = HTTP::Promise->new( threshold => 512000 );
        $p->threshold(512000);
        my $limit = $p->threshold;

  timeout
    Integer. Sets the timeout value. Defaults to 180 seconds, i.e. 3
    minutes.

    The request is aborted if no activity on the connection to the server is
    observed for "timeout" seconds. When a request times out, a response
    object is still returned. The response object will have a standard http
    status code of 500, i.e. server error. This response will have the
    "Client-Warning" header set to the value of "Internal response".

    Returns a number object

        my $p = HTTP::Promise->new( timeout => 10 );
        $p->timeout(10);
        my $timeout = $p->timeout;

  upgrade_insecure_requests
    This is an alias for "auto_switch_https"

  uri_escape
    URI-escape the given string using "uri_escape" in URI::Escape::XS

  uri_unescape
    URI-unescape the given string using "uri_unescape" in URI::Escape::XS

  use_content_file
    Boolean. Enables or disables the use of a temporary file to store the
    response content. Defaults to false.

    When true, the response content will be stored into a temporary file,
    whose object is a Module::Generic::File object and can be retrieved with
    "file".

  use_promise
    Boolean. When true, this will have HTTP::Promise HTTP methods return a
    HTTP::Promise, and when false, it returns directly the
    HTTP::Promise::Response. Defaults to true.



( run in 0.778 second using v1.01-cache-2.11-cpan-39bf76dae61 )