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