line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Protocol::SPDY::Stream; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Protocol::SPDY::Stream::VERSION = '1.000'; |
4
|
|
|
|
|
|
|
} |
5
|
4
|
|
|
4
|
|
585
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
124
|
|
6
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
115
|
|
7
|
4
|
|
|
4
|
|
906
|
use parent qw(Mixin::Event::Dispatch); |
|
4
|
|
|
|
|
275
|
|
|
4
|
|
|
|
|
24
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Protocol::SPDY::Stream - single stream representation within a L connection |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
version 1.000 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# You'd likely be using a subclass or other container here instead |
20
|
|
|
|
|
|
|
my $spdy = Protocol::SPDY->new; |
21
|
|
|
|
|
|
|
# Create initial stream - this example is for an HTTP request |
22
|
|
|
|
|
|
|
my $stream = $spdy->create_frame( |
23
|
|
|
|
|
|
|
# 0 is the default, use 1 if you don't want anything back from the |
24
|
|
|
|
|
|
|
# other side, for example server push |
25
|
|
|
|
|
|
|
unidirectional => 0, |
26
|
|
|
|
|
|
|
# Set to 1 if we're not expecting to send any further frames on this stream |
27
|
|
|
|
|
|
|
# - a GET request with no additional headers for example |
28
|
|
|
|
|
|
|
fin => 0, |
29
|
|
|
|
|
|
|
# Normally headers are provided as an arrayref to preserve order, |
30
|
|
|
|
|
|
|
# but for convenience you could use a hashref instead |
31
|
|
|
|
|
|
|
headers => [ |
32
|
|
|
|
|
|
|
':method' => 'PUT', |
33
|
|
|
|
|
|
|
':path:' => '/some/path?some=param', |
34
|
|
|
|
|
|
|
':version' => 'HTTP/1.1', |
35
|
|
|
|
|
|
|
':host' => 'localhost:1234', |
36
|
|
|
|
|
|
|
':scheme' => 'https', |
37
|
|
|
|
|
|
|
] |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
# Update the headers - regular HTTP allows trailing headers, with SPDY |
40
|
|
|
|
|
|
|
# you can send additional headers at any time |
41
|
|
|
|
|
|
|
$stream->headers( |
42
|
|
|
|
|
|
|
# There's more to come |
43
|
|
|
|
|
|
|
fin => 0, |
44
|
|
|
|
|
|
|
# Again, arrayref or hashref are allowed here |
45
|
|
|
|
|
|
|
headers => [ |
46
|
|
|
|
|
|
|
'content-length' => 5, |
47
|
|
|
|
|
|
|
] |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
# Normally scalar (byte) data here, although scalar ref (\'something') |
50
|
|
|
|
|
|
|
# and Future are also allowed |
51
|
|
|
|
|
|
|
$stream->send_data('hello'); |
52
|
|
|
|
|
|
|
# as a scalar ref: |
53
|
|
|
|
|
|
|
# $stream->send_data(\(my $buffer = "some data")); |
54
|
|
|
|
|
|
|
# as a Future: |
55
|
|
|
|
|
|
|
# $stream->send_data(my $f = Future->new); |
56
|
|
|
|
|
|
|
# $f->done('the data you expected'); |
57
|
|
|
|
|
|
|
# If you want to cancel the stream at any time, use ->reset |
58
|
|
|
|
|
|
|
$stream->reset('CANCEL'); # or STREAM_CANCEL if you've imported the constants |
59
|
|
|
|
|
|
|
# Normally you'd indicate finished by marking a data packet as the final one: |
60
|
|
|
|
|
|
|
$stream->send_data(' |