NAME
Protocol::SPDY::Base - abstract support for the SPDY protocol
VERSION
version 1.001
DESCRIPTION
Provides the base class for client, server and generic (proxy/analysis) SPDY handling.
METHODS
new
Instantiates a new SPDY-handling object. Applies any attributes passed as named parameters.
sender_zlib
The compression instance used for sending data.
receiver_zlib
Compression instance used for receiving (decompressing) data.
request_close
Issue a close request by sending a GOAWAY message.
restore_initial_settings
Send back the list of settings we'd previously persisted.
Typically called immediately after establishing the connection.
send_settings
Sends a SETTINGS frame generated from the key/value pairs passed to this method.
Typically called immediately after establishing the connection.
Example:
$spdy->send_settings(
initial_window_size => 32768,
max_concurrent_streams => 16,
);
check_version
Called before we do anything with a control frame.
Returns true if it's supported, false if not.
next_stream_id
Generate the next stream ID for this connection.
Returns the next available stream ID, or 0 if we're out of available streams
queue_frame
Requests sending the given $frame
at the earliest opportunity.
on_read
This is the method that an external transport would call when it has some data received from the other side of the SPDY connection. It expects to be called with a scalar containing bytes which can be decoded as SPDY frames; any SSL/TLS decoding should happen before passing data to this method.
Will call "dispatch_frame" for any valid frames that can be extracted from the stream.
prioritise_incoming_frames
Given a list of Protocol::SPDY::Frame instances, returns them reordered so that higher-priority items such as PING are handled first.
Does not yet support stream priority.
dispatch_frame
Dispatches the given frame to appropriate handlers - this will be the matching Protocol::SPDY::Stream if one exists, or internal connection state handling for GOAWAY/SETTINGS frames.
dispatch_unhandled_frame
Called when we receive a frame that's not been picked up by the usual handlers - could be a SYN_REPLY on a stream that we don't have, for example.
incoming_stream
Called when a new SYN_STREAM frame is received.
related_stream
Returns the Protocol::SPDY::Stream matching the stream_id for this frame (if it has one).
Will return undef if we have no stream yet or this frame does not have a stream_id.
apply_settings
Applies the given settings to our internal state.
extract_frame
Given a scalar reference to a byte buffer, this will extract the first frame if possible and return the bytes if it succeeded, undef if not. No frame validation is performed: the bytes are extracted based on the length information only.
parse_frame
Parse a frame extracted by "extract_frame". Returns an appropriate subclass of Protocol::SPDY::Frame if this succeeded, dies if it fails.
goaway
Requests termination of the connection.
ping
Sends a ping request. We should get a PING packet back as a high-priority reply.
settings
Send settings to the remote.
credential
Sends credential information to the remote.
version
Returns the version supported by this instance. Currently, this is always 3.
last_stream_id
The ID for the last stream we created.
write
Calls the external code which is expected to handle writes.
create_stream
Instantiate a new stream, returning the Protocol::SPDY::Stream instance.
pending_send
Returns a count of the frames that are waiting to be sent.
has_stream
Returns true if we have a stream matching the ID on the provided Protocol::SPDY::Stream instance.
stream_by_id
Returns the Protocol::SPDY::Stream matching the given ID.
expected_upload_bandwidth
The expected rate (kilobyte/sec) we can send data to the other side.
expected_download_bandwidth
The rate (kilobyte/sec) we expect to be able to receive data from the other side.
expected_round_trip_time
The rate (kilobyte/sec) we expect to be able to receive data from the other side.
max_concurrent_streams
The rate (kilobyte/sec) we expect to be able to receive data from the other side.
current_cwnd
The rate (kilobyte/sec) we expect to be able to receive data from the other side.
download_retrans_rate
The rate (kilobyte/sec) we expect to be able to receive data from the other side.
initial_window_size
The rate (kilobyte/sec) we expect to be able to receive data from the other side.
client_certificate_vector_size
The rate (kilobyte/sec) we expect to be able to receive data from the other side.
METHODS - Futures
batch
Future representing the current batch of frames being processed. Used for deferring window updates.
EVENTS
The following events may be raised by this class - use "subscribe_to_event" in Mixin::Event::Dispatch to watch for them:
$spdy->subscribe_to_event(
send_frame => sub {
my ($ev, $frame) = @_;
print "Send: $frame\n";
$ev->unsubscribe if $frame->type_name eq 'GOAWAY';
}
);
send_frame event
Called with the Protocol::SPDY::Frame instance just before we attempt to send a frame to the other side.
receive_frame event
Called with the Protocol::SPDY::Frame instance just before we attempt to process a frame received from the other side.
ping event
Called when we have received a PING request, just before we send back the reply.
stream event
Called after we have created a new stream in response to an incoming packet.
setting event
Called for each new SETTINGS entry received from the other side, just before we have applied the value locally.
INHERITED METHODS
- Mixin::Event::Dispatch
-
add_handler_for_event, clear_event_handlers, event_handlers, invoke_event, subscribe_to_event, unsubscribe_from_event
AUTHOR
Tom Molesworth <cpan@perlsite.co.uk>
LICENSE
Copyright Tom Molesworth 2011-2015. Licensed under the same terms as Perl itself.