HTTP::Promise::Body::Scalar - HTTP Message Body Scalar Class
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;
v0.1.0
This class represents an entity body as a scalar.
This class inherits from HTTP::Promise::Body and Module::Generic::Scalar
Methods superseded by this class are as follow.
This returns a new scalar object containing the body data.
Returns a md6 checksum of the body data using Crypt::Digest::MD5.
This returns nothing since there is no filepath for an all-memory body data
This calls "reset" in Module::Generic::Scalar to empty the underlying body data.
Jacques Deguest <jack@deguest.jp>
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(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.
To install HTTP::Promise, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTTP::Promise
CPAN shell
perl -MCPAN -e shell install HTTP::Promise
For more information on module installation, please visit the detailed CPAN module installation guide.