Protocol::SPDY - abstract support for the SPDY protocol
version 0.001
NOTE: This is a rewrite of the original Protocol::SPDY implementation, and as such is still very much in an early stage of development. Primary focus is on providing server-side SPDY implementation for use with browsers such as Chrome and Firefox (at the time of writing, the development track for Firefox11 has initial SPDY support).
Provides an implementation for the SPDY protocol at an abstract (in-memory buffer) level. This means that these modules aren't much use on their own, since they only deal with the abstract protocol. If you want to add SPDY client or server support to your code, you'll need a transport as well - try one of these yet-to-be-released modules:
Net::Async::SPDY::Server - serve SPDY requests using IO::Async
Net::Async::SPDY::Client - connect to SPDY servers using IO::Async (although once this is stable support may be added to Net::Async::HTTP, see https://rt.cpan.org/Ticket/Display.html?id=74387 for progress on this.
Eventually POE or AnyEvent implementations may arrive if someone more familiar with those frameworks takes an interest. On the server side, it should be possible to incorporate this as a plugin for Plack/PSGI so that any PSGI-compatible web application can support SPDY requests.
For a simple blocking client and server implementation, see the examples/ directory.
The information in http://www.chromium.org/spdy may be useful when implementing clients (browsers).
This abstract protocol class requires a transport implementation.
You can inform a browser that SPDY is available through the Alternate-Protocol HTTP header:
Alternate-Protocol: <port>:<protocol>
For example:
Alternate-Protocol: 2443:spdy/2
This applies both to HTTP and HTTPS.
If the browser is already connected to the server using TLS, the TLS/NPN mechanism can be used to indicate that SPDY is available. Currently this requires openssl-1.1 or later, although the NPN extension should be simple enough to backport if needed (see http://www.ietf.org/id/draft-agl-tls-nextprotoneg-00.txt for details). Since the port is already connected, only the <protocol> part is required ('spdy/2' or 'spdy/3') when sending via TLS/NPN.
This information could also be provided via the Alternate-Protocol header:
Alternate-Protocol: 2443:spdy/2,443:npn-spdy/2,443:npn-spdy/3
If we want to close, send a GOAWAY message first
Called before we do anything with a control frame.
Returns true if it's supported, false if not.
Check whether we have established this stream before allowing it to continue
Returns true if it's okay, false if not.
Create a stream.
Returns the stream ID, or 0 if we can't create any more on this connection.
Generate the next stream ID for this connection.
Returns the next available stream ID, or 0 if we're out of available streams
Generate a SYN_STREAM packet.
Takes the following options:
Generate a SYN_REPLY packet.
Generate a RST_STREAM packet.
Generate a SETTINGS packet.
Generate a PING packet.
Generate a GOAWAY packet.
Generate a HEADERS packet.
Convert an incoming HTTP-over-SPDY packet into a data structure and send appropriate event(s).
Generate a response packet.
Further documentation can be found in the following modules:
Protocol::SPDY::Frame - generic frame class
Protocol::SPDY::Frame::Control - specific subclass for control frames
Protocol::SPDY::Frame::Data - specific subclass for data frames
Protocol::SPDY::Stream - handling for 'streams', which are somewhat analogous to individual HTTP requests
Since the protocol is still in flux, it may be advisable to keep an eye on http://www.chromium.org/spdy.
Tom Molesworth <cpan@entitymodel.com>
Copyright Tom Molesworth 2011-2012. Licensed under the same terms as Perl itself.
To install Protocol::SPDY, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Protocol::SPDY
CPAN shell
perl -MCPAN -e shell install Protocol::SPDY
For more information on module installation, please visit the detailed CPAN module installation guide.