The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

HTTP::Promise::Body::Scalar - HTTP Message Body Scalar Class

SYNOPSIS

    use HTTP::Promise::Body;
    my $body = HTTP::Promise::Body::Scalar->new || 
        die( HTTP::Promise::Body::Scalar->error, "\n" );
    my $body = HTTP::Promise::Body::Scalar->new( $some_data );

    if( $body->is_empty )
    {
        # do something
    }

    my $size = $body->length;

    # $io is a Module::Generic::Scalar::IO object
    my $io = $body->open( 'r' ) || die( $body->error );
    $io->read( $buffer, 2048 );
    $io->close;

    my $io = $body->open( 'r', { binmode => 'utf-8' } ) || die( $body->error );
    $io->read( $buffer, 2048 );
    $io->close;

    # open the body as an utf-8 stream and print it to filehandle $filehandle
    $body->print( $filehandle, { binmode => 'utf-8' } );

    # $lines is a new Module::Generic::Array
    my $lines = $body->split( qr/\n/ );

    $body->purge;
    # ditto
    $body->reset;

VERSION

    v0.1.0

DESCRIPTION

This class represents an entity body as a scalar.

This class inherits from HTTP::Promise::Body and Module::Generic::Scalar

METHODS

Methods superseded by this class are as follow.

as_string

This returns a new scalar object containing the body data.

checksum_md5

Returns a md6 checksum of the body data using Crypt::Digest::MD5.

path

This returns nothing since there is no filepath for an all-memory body data

purge

This calls "reset" in Module::Generic::Scalar to empty the underlying body data.

AUTHOR

Jacques Deguest <jack@deguest.jp>

SEE ALSO

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

Module::Generic::File, Module::Generic::Scalar, Module::Generic::File::IO, Module::Generic::Scalar::IO

PerlIO::scalar

COPYRIGHT & LICENSE

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.