view release on metacpan or search on metacpan
t/lib/TestApp/Controller/Action/Streaming.pm view on Meta::CPAN
package TestApp::Controller::Action::Streaming;
use strict;
use base 'TestApp::Controller::Action';
sub streaming : Global {
my ( $self, $c ) = @_;
for my $line ( split "\n", <<'EOF' ) {
foo
bar
baz
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Engine/PSGI.pm view on Meta::CPAN
=item *
Your application is supposed to work with any PSGI servers without any
code modifications, but if your application uses C<< $c->res->write >>
to do streaming write, this engine will buffer the ouput until your
app finishes.
To do real streaming with this engine, you should implement an
IO::Handle-like object that responds to C<getline> method that returns
chunk or undef when done, and set that object to C<< $c->res->body >>.
Alternatively, it is possible to set the body to a code reference,
which will be used to stream content as documented in the
view all matches for this distribution
view release on metacpan or search on metacpan
0.10 2009-02-08
- POD addition.
- Switch from NEXT to MRO::Compat
0.09 2007-10-08
- Bump dependencies so that streaming a file also causes the cookie to
be updated.
- Add tests for this
0.08 2007-09-14
- Fix live test with Mech version 0.37+
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Plugin/Session/Store/Cookie.pm view on Meta::CPAN
a bunch of stuff into the user session, this will likely not work out.
B<NOTE> Since we need to store all the session info in the cookie, the session
state will be set at ->finalize_headers stage (rather than at ->finalize_body
which is the default for session storage plugins). What this means is that if
you use the streaming or socket interfaces ($c->response->write, $c->response->write_fh
and $c->req->io_fh) your session state will get saved early. For example you
cannot do this:
$c->res->write("some stuff");
$c->session->{key} = "value";
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Plugin/Session/Store.pm view on Meta::CPAN
However some storage plugins may wish to finalize earlier, during header
finalization. For example a storage that saved state in a client cookie
would wish this. If a storage plugin wants to finalize early it should set
$c->_needs_early_session_finalization to true. Please note that if you
do this in a storage plugin, you should warn users not to attempt to change
or add session keys if you use a streaming or socket interface such as
$c->res->write, $c->res->write_fh or $c->req->io_fh.
=cut
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst.pm view on Meta::CPAN
Make sure your body is encoded properly IF you set an encoding. By
default the encoding is UTF-8 but you can disable it by explicitly setting the
encoding configuration value to undef.
We can only encode when the body is a scalar. Methods for encoding via the
streaming interfaces (such as C<write> and C<write_fh> on L<Catalyst::Response>
are available).
See L</ENCODING>.
=cut
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CatalystX/Crudite/Util/Random.pm view on Meta::CPAN
streaks
stream
streamed
streamer
streamers
streaming
streamline
streamlined
streamliner
streamlines
streamlining
view all matches for this distribution
view release on metacpan or search on metacpan
Changelog for Catmandu-RDF
0.32 2017-08-29 13:23:32 CEST
- Fixing SPARQL examples with latest RDF::LDF
- Better support for streaming RDF input
- Adding a --speed option to the Catmandu::Importer::RDF
0.31 2016-04-13 10:24:55 CEST
- Fix test failure caused by RDF::NS (#29)
0.29 2016-03-30 14:28:27 CEST
- provide caching support for HTTP access
0.28 2015-11-25 11:35:42 CET
- streaming export in NTriples format by default (issue #25)
0.27 2015-05-30 14:15:45 CEST
- added sparql file option (issue #19)
0.26 2015-05-21 10:38:12 CEST
- added support of Linked Data Fragments
0.25 2015-03-27 13:53:59 CET
- support streaming of NTriple data
0.24 2015-03-09 13:20:23 CET
- added support of SPARQL
- fixed some unit tests
- rewrote aref_query fix
view all matches for this distribution
view release on metacpan or search on metacpan
t/Catmandu-Exporter-Text.t view on Meta::CPAN
);
isa_ok $exporter, 'Catmandu::Exporter::Text';
$exporter->add_many($data);
# don't call commit to test streaming output
is $exporter->count, 3, 'Count ok';
is $file, "moose\tpony\tshrimp,lobster\t", 'Text doc array';
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Chart/Clicker.pm view on Meta::CPAN
Get the dataset at the specified index.
=head2 rendered_data
Returns the data for this chart as a scalar. Suitable for 'streaming' to a
client.
=head2 add_to_over_decorations
Add an over decoration to the list.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Chatbot/Alpha.pm view on Meta::CPAN
the stream cache will be loaded (assuming FILE_PATH is omitted). You shouldn't need to worry about using STREAM, see
the "stream" method below.
=head2 stream (ALPHA_CODE)
Inputs a set of Alpha code directly into the module ("streaming") rather than loading it from an external document.
See synopsis for an example.
=head2 sortReplies
Sorts the replies already loaded: solid triggers go first, followed by triggers containing wildcards. If you fail to
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Claude/Agent.pm view on Meta::CPAN
prompt => $prompt,
options => $options,
loop => $loop, # optional, for async integration
);
Creates a new query and returns an iterator for streaming messages.
=head3 Arguments
=over 4
view all matches for this distribution
view release on metacpan or search on metacpan
eg/clickhouse_replication.pl view on Meta::CPAN
#!/usr/bin/env perl
# Replicate one ClickHouse table to another (potentially on a different
# server) by streaming Native bytes end-to-end -- no Perl-side row
# decode at all. The encoder isn't strictly needed here since both
# sides speak Native, but for_table() validates the destination schema
# and the script demonstrates the streaming pipe pattern users build
# their own variants on (filtering, transforms, etc.).
#
# This is the "free" case: source select format native, destination
# insert format native, identical schemas. With matching schemas the
# server-side codepath is a copy through the column ColumnPtr layer,
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Clio/Server/HTTP/Client/Stream.pm view on Meta::CPAN
$Clio::Server::HTTP::Client::Stream::AUTHORITY = 'cpan:AJGB';
}
{
$Clio::Server::HTTP::Client::Stream::VERSION = '0.02';
}
# ABSTRACT: Clio HTTP Client for streaming connections
use strict;
use Moo;
use Scalar::Util qw( blessed );
lib/Clio/Server/HTTP/Client/Stream.pm view on Meta::CPAN
=encoding utf-8
=head1 NAME
Clio::Server::HTTP::Client::Stream - Clio HTTP Client for streaming connections
=head1 VERSION
version 0.02
=head1 DESCRIPTION
# HTTP server with streaming clients
<Server>
Listen 0:12345
Class HTTP
lib/Clio/Server/HTTP/Client/Stream.pm view on Meta::CPAN
OutputFilter LineEnd
</Client>
</Server>
HTTP server with streaming capabilities.
Process output is streamed directly to client - the above example can be used
directly in a browser for read only data.
Extends of L<Clio::Client>.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Collection/AutoSQL.pm view on Meta::CPAN
Return list of ids
params:
flow - Flow:: object for streaming results
onpage - [pagination] count of ids on page
page - [pagination] requested page ( depend on onpage)
exp - ref to expression for select
desc - revert sorting ([1,0])
where - custom where if needed, instead expr ['where sring', $query_param1,..]
view all matches for this distribution
view release on metacpan or search on metacpan
return lib_find_subdevice_by_type($self->{handle}, $type, $start);
}
=item get_read_subdevice
Find streaming input subdevice.
Example code,
my $streaming_input_support = $cref->get_read_subdevice();
if ($streaming_input_support == -1) {
print "No streaming input support available\n";
}
else {
print "Comedi subdevice no. $streaming_input_support ",
"allows streaming input\n";
}
This class method returns the subdevice whose streaming input buffer is
accessible through the previous opened device. If there is no such subdevice,
-1 is returned.
=cut
return lib_get_read_subdevice($self->{handle});
}
=item get_write_subdevice
Find streaming output subdevice.
Example code,
my $streaming_output_support = $cref->get_write_subdevice();
if ($streaming_output_support == -1) {
print "No streaming output support available\n";
}
else {
print "Comedi subdevice no. $streaming_output_support ",
"allows streaming output\n";
}
This class method returns the subdevice whose streaming output buffer is
accessible through the previous opened device. If there is no such subdevice,
-1 is returned.
=cut
my $buf_size = $cref->get_buffer_size($subdev);
croak "An error has occurred" if $buf_size == -1;
print "Streaming buffer size for the subdevice - $buf_size Bytes\n";
This class method returns the size -in Bytes- of the streaming buffer for the
specified subdevice. On error, -1 is returned.
=cut
sub get_buffer_size {
return lib_get_buffer_size($self->{handle}, $subdev);
}
=item get_max_buffer_size
Maximum streaming buffer size.
Example code,
my $max_size = $cref->get_max_buffer_size($subdev);
croak "An error has occurred" if $max_size == -1;
print "Max. streaming buffer size for the subdevice - $max_size Bytes\n";
This class method returns the maximum allowable size -in Bytes- of the
streaming buffer for the specified subdevice. On error, -1 is returned.
=cut
sub get_max_buffer_size {
my $self = shift;
require POSIX;
my $vmps = POSIX::sysconf(&POSIX::_SC_PAGESIZE);
$vmps *= 2;
print "Trying to set the streaming buffer size to $vmps\n";
if ($cref->set_buffer_size($subdev, $vmps) == -1) {
print "Warning: Couldn't set new streaming buffer size\n";
}
The C<set_buffer_size()> class method returns the new buffer size in Bytes.
On error, -1 is returned.
return;
}
=item cancel
Stop streaming input/output in progress.
Example code,
# This class method is useful in combination with command()
# and this class method is not completely implemented yet.
return lib_cancel($self->{handle}, $subdev);
}
=item command
Start streaming input/output.
Note that this subroutine has no functionality as long as I have no testing
device with the associated driver.
Patches or suggestions are welcome, send me an email (Subject: Comedi::Lib).
return;
}
=item command_test
Test streaming input/output configuration.
Note that this subroutine has no functionality as long as I have no testing
device with the associated driver.
Patches or suggestions are welcome, send me an email (Subject: Comedi::Lib).
return;
}
=item poll
Force updating of streaming buffer.
Example code,
my $retval = $cref->poll($subdev);
croak "An error has occurred" if $retval == -1;
# This class method is useful in combination with command()
# and this class method is not completely implemented yet.
This class method returns the number of bytes that are available in the
streaming buffer. If there is an error, -1 is returned.
=cut
sub get_buffer_contents {
print STDERR __PACKAGE__, '::',
# This class method is useful in combination with command()
# and this class method is not completely implemented yet.
This class method returns the offset in bytes of the read pointer in the
streaming buffer. If there is an error, -1 is returned.
=cut
sub get_buffer_offset {
print STDERR __PACKAGE__, '::',
view all matches for this distribution
view release on metacpan or search on metacpan
t/app/Plack/Handler/Apache1.t view on Meta::CPAN
],
},
},
},
right => branch { '=>',
left => leaf 'psgi.streaming',
right => function_call { 'Plack::Util::TRUE',
args => [
],
},
},
t/app/Plack/Handler/Apache1.t view on Meta::CPAN
'psgi.input' => $r,
'psgi.errors' => *STDERR,
'psgi.multithread' => Plack::Util::FALSE,
'psgi.multiprocess' => Plack::Util::TRUE,
'psgi.run_once' => Plack::Util::FALSE,
'psgi.streaming' => Plack::Util::TRUE,
'psgi.nonblocking' => Plack::Util::FALSE,
'psgix.harakiri' => Plack::Util::TRUE,
};
if (defined(my $HTTP_AUTHORIZATION = $r->headers_in->{Authorization})) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Compress/BGZF/Reader.pm view on Meta::CPAN
$reader->write_index( $fn_idx );
=head1 DESCRIPTION
C<Compress::BGZF::Reader> is a module implementing random access to the BGZIP file
format. While it can do sequential/streaming reads, there is really no point
in using it for this purpose over standard GZIP tools/libraries, since BGZIP
is GZIP-compatible.
There are two main modes of construction - as an object (using C<new()>) and
as a filehandle glob (using C<new_filehandle>). The filehandle mode is
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Compress/Bzip2.pm view on Meta::CPAN
Note that each such block has an overhead of leading and trailing
synchronization bytes. bzip2 recovery uses this information to
pull useable data out of a corrupted file.
A streaming application would probably want to set the blocking low.
=item B<-workFactor>
For bzip object opened for stream deflation or write.
lib/Compress/Bzip2.pm view on Meta::CPAN
=head1 Compress::Bzip2 1.03 COMPATIBILITY
While the 2.x thread forked off of 1.00, another line of development
came to a head at 1.03. The 1.03 version worked with bzlib 1.0.2, had
improvements to the error handling, single buffer inflate/deflate, a
streaming interface to inflate/deflate, and a cpan style test suite.
=head2 B<$dest = compress( $string, [$level] )>
Alias to L<memBzip>, this compresses string, using the optional
compression level, 1 through 9, the default being 6. Returns a string
lib/Compress/Bzip2.pm view on Meta::CPAN
Note that each such block has an overhead of leading and trailing
synchronization bytes. bzip2 recovery uses this information to
pull useable data out of a corrupted file.
A streaming application would probably want to set the blocking low.
=item B<-workFactor>
The workFactor setting tells the deflation algorithm how much work
to invest to compensate for repetitive data.
lib/Compress/Bzip2.pm view on Meta::CPAN
I<Compress::Bzip2> was subsequently passed on to Marco Carnut
F<kiko@tempest.com.br> who shepherded it through to version 1.03, a
set of changes which included upgrades to handle bzlib 1.0.2, and
improvements to the in memory inflate and deflate routines. The
streaming interface and error information were added by David Robins
F<dbrobins@davidrobins.net>.
Version 2 of I<Compress::Bzip2> is due to Rob Janes, of
arjay@cpan.org. This release is intended to give an interface
close to that of Compress::Zlib. It's development forks from 1.00,
not 1.03, so the streaming interface is not the same as that in 1.03,
although apparently compatible as it passes the 1.03 test suite.
Minor subsequent fixes and releases were done by Reini Urban,
rurban@cpan.org.
view all matches for this distribution
view release on metacpan or search on metacpan
$rec->set_quality( $orig_qual );
$rec->set_plus('+');
$w->write_record( $rec );
}
ok( $read_count > 0 && $read_count*4 == $passed,
"streaming records identical" );
$r->finish();
$w->finish();
ok( $m->decompress('bee.dsrc' => 'bee.fastq', 1),
"one-shot decompression 4" );
view all matches for this distribution
view release on metacpan or search on metacpan
{
return LZ4_decompress_generic(source, dest, 0, originalSize, endOnOutputSize, full, 0, withPrefix64k, (BYTE*)(dest - 64 KB), NULL, 64 KB);
}
/*===== streaming decompression functions =====*/
/*
* If you prefer dynamic allocation methods,
* LZ4_createStreamDecode()
* provides a pointer (void*) towards an initialized LZ4_streamDecode_t structure.
return 1;
}
/*
*_continue() :
These decoding functions allow decompression of multiple blocks in "streaming" mode.
Previously decoded blocks must still be available at the memory position where they were decoded.
If it's not possible, save the relevant part of decoded data into a safe buffer,
and indicate where it stands using LZ4_setStreamDecode()
*/
int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxOutputSize)
LZ4_stream_t_internal* ctx = &((LZ4_stream_t*)LZ4_Data)->internal_donotuse;
int dictSize = LZ4_saveDict((LZ4_stream_t*)LZ4_Data, (char*)ctx->bufferStart, 64 KB);
return (char*)(ctx->bufferStart + dictSize);
}
/* Obsolete streaming decompression functions */
int LZ4_decompress_safe_withPrefix64k(const char* source, char* dest, int compressedSize, int maxOutputSize)
{
return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, full, 0, withPrefix64k, (BYTE*)dest - 64 KB, NULL, 64 KB);
}
view all matches for this distribution
view release on metacpan or search on metacpan
{
return LZ4_decompress_generic(source, dest, 0, originalSize, endOnOutputSize, full, 0, withPrefix64k, (BYTE*)(dest - 64 KB), NULL, 64 KB);
}
/*===== streaming decompression functions =====*/
LZ4_streamDecode_t* LZ4_createStreamDecode(void)
{
LZ4_streamDecode_t* lz4s = (LZ4_streamDecode_t*) ALLOCATOR(1, sizeof(LZ4_streamDecode_t));
return lz4s;
return 1;
}
/*
*_continue() :
These decoding functions allow decompression of multiple blocks in "streaming" mode.
Previously decoded blocks must still be available at the memory position where they were decoded.
If it's not possible, save the relevant part of decoded data into a safe buffer,
and indicate where it stands using LZ4_setStreamDecode()
*/
LZ4_FORCE_O2_GCC_PPC64LE
LZ4_stream_t_internal* ctx = &((LZ4_stream_t*)LZ4_Data)->internal_donotuse;
int dictSize = LZ4_saveDict((LZ4_stream_t*)LZ4_Data, (char*)ctx->bufferStart, 64 KB);
return (char*)(ctx->bufferStart + dictSize);
}
/* Obsolete streaming decompression functions */
int LZ4_decompress_safe_withPrefix64k(const char* source, char* dest, int compressedSize, int maxOutputSize)
{
return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize, endOnInputSize, full, 0, withPrefix64k, (BYTE*)dest - 64 KB, NULL, 64 KB);
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Compress/Stream/Zstd.pm view on Meta::CPAN
Compress::Stream::Zstd - Perl interface to the Zstd (Zstandard) (de)compressor
=head1 NOTE
This module is a fork of L<Compress-Zstd|https://github.com/spiritloose/Compress-Zstd>.
It contains a few changes to make streaming compression/uncompression more robust.
The only reason for this fork is to allow the module to work with `IO-Compress-Zstd`.
The hope is that the changes made here can be merged back upstream and this module can be retired.
=head1 SYNOPSIS
lib/Compress/Stream/Zstd.pm view on Meta::CPAN
=head1 AUTHOR
Jiro Nishiguchi E<lt>jiro@cpan.orgE<gt>
Some streaming enhancement by Paul Marquess E<lt>pmqs@cpan.orgE<gt>
Zstandard by Facebook, Inc.
=cut
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Compress/Zopfli.pm view on Meta::CPAN
deflate libraries can decompress the data, i.e. I<IO::Compress>.
=head2 B<($compressed) = compress( $input, I<ZOPFLI_FORMAT>, [OPTIONS] ] )>
This is the only function provided by I<Compress::Zopfli>. The input must
be a string. The underlying function does not seem to support any streaming
interface.
=head1 OPTIONS
Options map directly to the I<zopfli> low-level function. Must be a hash
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Compress/Zstd/Compressor.pm view on Meta::CPAN
=encoding utf-8
=head1 NAME
Compress::Zstd::Compressor - Zstd streaming compression
=head1 SYNOPSIS
use Compress::Zstd::Compressor qw(ZSTD_CSTREAM_IN_SIZE);
lib/Compress/Zstd/Compressor.pm view on Meta::CPAN
}
print $compressor->end;
=head1 DESCRIPTION
The Compress::Zstd::Compressor module provides a streaming interface to the Zstd compressor.
=head1 METHODS
=head2 Compress::Zstd::Compressor->new([$level]) :Compress::Zstd::Compressor
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Conduit.pm view on Meta::CPAN
L<PAGI> support; likely in preference to any more PSGI.
=item *
Maybe support streaming PSGI responses, though it would still be preferrable
to do this with PAGI first.
=item *
Investigate split IPv4+IPv6 serving, whether it needs two socket or one will
view all matches for this distribution
view release on metacpan or search on metacpan
libucl-0.8.1/doc/api.md view on Meta::CPAN
# Description
Libucl is a parser and `C` API to parse and generate `ucl` objects. Libucl consist of several groups of functions:
### Parser functions
Used to parse `ucl` files and provide interface to extract `ucl` object. Currently, `libucl` can parse only full `ucl` documents, for instance, it is impossible to parse a part of document and therefore it is impossible to use `libucl` as a streaming...
### Emitting functions
Convert `ucl` objects to some textual or binary representation. Currently, libucl supports the following exports:
- `JSON` - valid json format (can possibly lose some original data, such as implicit arrays)
view all matches for this distribution
view release on metacpan or search on metacpan
examples/fatpacked.plackup view on Meta::CPAN
'psgi.input' => $input,
'psgi.errors' => *STDERR,
'psgi.multithread' => $FALSE,
'psgi.multiprocess' => $FALSE,
'psgi.run_once' => $TRUE,
'psgi.streaming' => $TRUE,
'psgi.nonblocking' => $FALSE,
@_,
};
for my $field ( $req->headers->header_field_names ) {
examples/fatpacked.plackup view on Meta::CPAN
'psgi.errors' => *STDERR,
'psgi.url_scheme' => $self->{ssl} ? 'https' : 'http',
'psgi.run_once' => Plack::Util::FALSE,
'psgi.multithread' => Plack::Util::FALSE,
'psgi.multiprocess' => Plack::Util::FALSE,
'psgi.streaming' => Plack::Util::TRUE,
'psgi.nonblocking' => Plack::Util::FALSE,
'psgix.harakiri' => Plack::Util::TRUE,
'psgix.input.buffered' => Plack::Util::TRUE,
'psgix.io' => $conn,
};
examples/fatpacked.plackup view on Meta::CPAN
'psgi.input' => $r,
'psgi.errors' => *STDERR,
'psgi.multithread' => Plack::Util::FALSE,
'psgi.multiprocess' => Plack::Util::TRUE,
'psgi.run_once' => Plack::Util::FALSE,
'psgi.streaming' => Plack::Util::TRUE,
'psgi.nonblocking' => Plack::Util::FALSE,
'psgix.harakiri' => Plack::Util::TRUE,
};
if (defined(my $HTTP_AUTHORIZATION = $r->headers_in->{Authorization})) {
examples/fatpacked.plackup view on Meta::CPAN
'psgi.input' => $r,
'psgi.errors' => *STDERR,
'psgi.multithread' => Plack::Util::FALSE,
'psgi.multiprocess' => Plack::Util::TRUE,
'psgi.run_once' => Plack::Util::FALSE,
'psgi.streaming' => Plack::Util::TRUE,
'psgi.nonblocking' => Plack::Util::FALSE,
'psgix.harakiri' => Plack::Util::TRUE,
'psgix.cleanup' => Plack::Util::TRUE,
'psgix.cleanup.handlers' => [],
};
examples/fatpacked.plackup view on Meta::CPAN
'psgi.input' => *STDIN,
'psgi.errors' => *STDERR,
'psgi.multithread' => 0,
'psgi.multiprocess' => 1,
'psgi.run_once' => 1,
'psgi.streaming' => 1,
'psgi.nonblocking' => 1,
%{ $override_env },
};
delete $env->{HTTP_CONTENT_TYPE};
examples/fatpacked.plackup view on Meta::CPAN
'psgi.errors' =>
($self->{keep_stderr} ? \*STDERR : $self->{stderr}),
'psgi.multithread' => Plack::Util::FALSE,
'psgi.multiprocess' => defined $proc_manager,
'psgi.run_once' => Plack::Util::FALSE,
'psgi.streaming' => Plack::Util::TRUE,
'psgi.nonblocking' => Plack::Util::FALSE,
'psgix.harakiri' => defined $proc_manager,
'psgix.cleanup' => 1,
'psgix.cleanup.handlers' => [],
};
examples/fatpacked.plackup view on Meta::CPAN
# child
close $read;
my $res;
try {
$env->{'psgi.streaming'} = 0;
$res = $self->{builder}->()->($env);
my @body;
Plack::Util::foreach($res->[2], sub { push @body, $_[0] });
$res->[2] = \@body;
} catch {
examples/fatpacked.plackup view on Meta::CPAN
return $res;
}
The tricky thing about post-processing the response is that it could
either be an immediate 3 element array ref, or a code reference that
implements the delayed (streaming) interface.
Dealing with these two types of response in each piece of middleware
is pointless, so you're recommended to use the C<response_cb> wrapper
function in L<Plack::Util> when implementing a post processing
middleware.
examples/fatpacked.plackup view on Meta::CPAN
return;
});
The third element of the response array ref is a body, and it could
be either an arrayref or L<IO::Handle>-ish object. The application could
also make use of the C<$writer> object if C<psgi.streaming> is in
effect, and in this case, the third element will not exist
(C<@$res == 2>). Dealing with these variants is again really painful,
and C<response_cb> can take care of that too, by allowing you to return
a content filter as a code reference.
examples/fatpacked.plackup view on Meta::CPAN
use parent qw(Plack::Middleware);
sub call {
my ( $self, $env ) = @_;
my $caller_supports_streaming = $env->{'psgi.streaming'};
$env->{'psgi.streaming'} = Plack::Util::TRUE;
my $res = $self->app->($env);
return $res if $caller_supports_streaming && !$self->force;
if ( ref($res) eq 'CODE' ) {
my $ret;
$res->(sub {
examples/fatpacked.plackup view on Meta::CPAN
__END__
=head1 NAME
Plack::Middleware::BufferedStreaming - Enable buffering for non-streaming aware servers
=head1 SYNOPSIS
enable "BufferedStreaming";
=head1 DESCRIPTION
Plack::Middleware::BufferedStreaming is a PSGI middleware component
that wraps the application that uses C<psgi.streaming> interface to
run on the servers that do not support the interface, by buffering the
writer output to a temporary buffer.
This middleware doesn't do anything and bypass the application if the
server supports C<psgi.streaming> interface, unless you set C<force>
option (see below).
=head1 OPTIONS
=over 4
=item force
Force enable this middleware only if the container supports C<psgi.streaming>.
=back
=head1 AUTHOR
examples/fatpacked.plackup view on Meta::CPAN
Plack::Middleware::JSONP wraps JSON response, which has Content-Type
value either C<text/javascript> or C<application/json> as a JSONP
response which is specified with the C<callback> query parameter. The
name of the parameter can be set while enabling the middleware.
This middleware only works with a non-streaming response, and doesn't
touch the response otherwise.
=head1 AUTHOR
Tatsuhiko Miyagawa
examples/fatpacked.plackup view on Meta::CPAN
}
unless ($env->{'psgi.url_scheme'} =~ /^https?$/) {
die("psgi.url_scheme should be 'http' or 'https': ", $env->{'psgi.url_scheme'});
}
if ($env->{"psgi.version"}->[1] == 1) { # 1.1
for my $param (qw(streaming nonblocking run_once)) {
unless (exists $env->{"psgi.$param"}) {
die("Missing psgi.$param");
}
}
}
examples/fatpacked.plackup view on Meta::CPAN
*{$fh}{IO} &&
*{$fh}{IO}->can('getline');
}
sub validate_res {
my ($self, $res, $streaming) = @_;
unless (ref($res) eq 'ARRAY' or ref($res) eq 'CODE') {
die("Response should be array ref or code ref: $res");
}
if (ref $res eq 'CODE') {
return $self->response_cb($res, sub { $self->validate_res(@_, 1) });
}
unless (@$res == 3 || ($streaming && @$res == 2)) {
die('Response needs to be 3 element array, or 2 element in streaming');
}
unless ($res->[0] =~ /^\d+$/ && $res->[0] >= 100) {
die("Status code needs to be an integer greater than or equal to 100: $res->[0]");
}
examples/fatpacked.plackup view on Meta::CPAN
unless (defined $val) {
die("Response headers MUST be a defined string. Header: $key");
}
}
# @$res == 2 is only right in psgi.streaming, and it's already checked.
unless (@$res == 2 ||
ref $res->[2] eq 'ARRAY' ||
Plack::Util::is_real_fh($res->[2]) ||
is_possibly_fh($res->[2]) ||
(blessed($res->[2]) && $res->[2]->can('getline'))) {
examples/fatpacked.plackup view on Meta::CPAN
use L<Plack::Middleware::HTTPExceptions> in the deployment mode as a
replacement, so that all the exceptions thrown from your application
still get caught and rendered as a 500 error response, rather than
crashing the web server.
Catching errors in streaming response is not supported.
=head2 Stack Trace Module
The L<Devel::StackTrace::WithLexicals> module will be used to capture the stack trace
if the installed version is 0.08 or later. Otherwise L<Devel::StackTrace> is used.
examples/fatpacked.plackup view on Meta::CPAN
is $res->header('content_type'), 'text/plain';
is $res->content, 'Hello, name=miyagawa';
},
sub {
my $env = shift;
$env->{'psgi.streaming'} or return [ 501, ['Content-Type','text/plain'], [] ];
return sub {
my $respond = shift;
$respond->([
200,
[ 'Content-Type' => 'text/plain', ],
examples/fatpacked.plackup view on Meta::CPAN
]);
}
},
],
[
'coderef streaming',
sub {
my $cb = shift;
my $res = $cb->(GET "http://127.0.0.1/?name=miyagawa");
return if $res->code == 501;
examples/fatpacked.plackup view on Meta::CPAN
is $res->header('content_type'), 'text/plain';
is $res->content, 'Hello, name=miyagawa';
},
sub {
my $env = shift;
$env->{'psgi.streaming'} or return [ 501, ['Content-Type','text/plain'], [] ];
return sub {
my $respond = shift;
my $writer = $respond->([
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Continuity/Adapt/PSGI.pm view on Meta::CPAN
# comes in
my $app = sub {
my $env = shift;
unless ($env->{'psgi.streaming'}) {
die 'This application needs psgi.streaming support!';
}
# stuff $env onto a queue that get_request above pulls from; get_request is
# called from Continuity's main execution context/loop. Continuity's main
# execution loop invokes the Mapper to send the request across a queue to
view all matches for this distribution
view release on metacpan or search on metacpan
t/04-api-stream-omop.t view on Meta::CPAN
sep => "\t",
method => 'omop2bff',
);
SKIP: {
skip q{share/db/ohdsi.db is required for streaming CSV.gz OMOP test}, 1
unless has_ohdsi_db();
$convert->omop2bff;
is(
gunzip_file_content('t/omop2bff/out/individuals_csv.json.gz'),
gunzip_file_content($tmp_file),
view all matches for this distribution