File: body-types.psgi

package info (click to toggle)
uwsgi 2.0.29-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 6,684 kB
  • sloc: ansic: 87,027; python: 7,001; cpp: 1,131; java: 708; perl: 678; sh: 585; ruby: 555; makefile: 148; xml: 130; cs: 121; objc: 37; php: 28; erlang: 20; javascript: 11
file content (43 lines) | stat: -rw-r--r-- 1,509 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use strict;
use warnings;

use FileHandle;
use IO::File;
use IO::String;

my $code = do { local ( @ARGV, $/ ) = __FILE__; <> };

sub ObjectPath::path { __FILE__ }

sub {
    my $path = shift->{PATH_INFO};

    my $body = $path eq '/Array'      ? [ split //, $code ]
             : $path eq '/Code'       ? sub {}
             : $path eq '/DATA'       ? \*DATA
             : $path eq '/DIRHANDLE'  ? do { opendir my $fh, '.'; $fh }
             : $path eq '/FILEHANDLE' ? do { open my $fh, __FILE__; $fh }
             : $path eq '/FileHandle' ? FileHandle->new(__FILE__)
             : $path eq '/Float'      ? 3.14
             : $path eq '/FloatRef'   ? \3.14
             : $path eq '/Format'     ? *STDOUT{FORMAT}
             : $path eq '/FormatRef'  ? \*STDOUT{FORMAT}
             : $path eq '/IO::File'   ? IO::File->new(__FILE__)
             : $path eq '/Hash'       ? { foo => 'bar' }
             : $path eq '/Int'        ? 3
             : $path eq '/IntRef'     ? \3
             : $path eq '/IO::String' ? IO::String->new($code)
             : $path eq '/Object'     ? bless({})
             : $path eq '/ObjectPath' ? bless( {}, 'ObjectPath' )
             : $path eq '/Regexp'     ? qr/foo/
             : $path eq '/String'     ? 'foo'
             : $path eq '/StringRef'  ? \'bar'
             : $path eq '/Undef'      ? undef
             : $path eq '/UndefRef'   ? \undef
             : return [ 404, [], [] ];

    [ 200, [ 'X-ref' => ref $body ], $body ];
};

__DATA__
data data data