Giter VIP home page Giter VIP logo

stream-buffered's Introduction

NAME

Stream::Buffered - temporary buffer to save bytes

SYNOPSIS

my $buf = Stream::Buffered->new($length);
$buf->print($bytes);

my $size = $buf->size;
my $fh   = $buf->rewind;

DESCRIPTION

Stream::Buffered is a buffer class to store arbitrary length of byte strings and then get a seekable filehandle once everything is buffered. It uses PerlIO and/or temporary file to save the buffer depending on the length of the size.

SEE ALSO

Plack::Request

AUTHOR

Tatsuhiko Miyagawa

This module is part of Plack, released as a separate distribution for easier reuse.

COPYRIGHT

The following copyright notice applies to all the files provided in this distribution, including binary files, unless explicitly noted otherwise.

Copyright 2009-2011 Tatsuhiko Miyagawa

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

stream-buffered's People

Contributors

doy avatar

Stargazers

Christopher Layne avatar  avatar

Watchers

Tatsuhiko Miyagawa avatar Tomas Doran avatar Graham Knop avatar  avatar James Cloos avatar

stream-buffered's Issues

$buffer->print should return a truthy value on success.

Currently Catalyst expects ->print to return a truthy value on success. This is is likely because that's how perl's internal print works. That seems like a reasonable API and what most people using this module would expect. Currently it the return value appears to be undocumented, so clarifying that and making it always truthy should not break things.

While normally returning the thing printed would be a truthy value, ->print(0) or ->print("") would not.

I did also file a Catalyst-Runtime bug letting them know they're not correctly using String::Buffered and pointing them at this issue.

Buffer is different if ::File or ::PerlIO is used (with test)

mking@hal:~/src$ perl -MStream::Buffered::File -MStream::Buffered::PerlIO -E '

# A sort of script plus test case

sub buf { my $fh = shift->rewind; local $/; <$fh> }
my $file = Stream::Buffered::File->new;
$file->print(qw(a b c));
say "-" . buf($file) . "-";
my $perlio = Stream::Buffered::PerlIO->new;
$perlio->print(qw(a b c));
say "+" . buf($perlio) . "+";
exit ! buf($file) == buf($perlio); # Should be 0

'
-abc-
+a b c+

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.