NAME

Net::SPDY::Framer - SPDY protocol implementation

ALPHA WARNING

Please read carefully: This is an ALPHA stage software. In particular this means that even though it probably won't kill your cat, re-elect George W. Bush nor install Solaris 11 Express edition to your hard drive, it is in active development, functionality is missing and no APIs are stable.

See TODO file in the distribution to learn about missing and planned functionality. You are more than welcome to join the development and submit patches with fixes or enhancements. Bug reports are probably not very useful at this point.

SYNOPSIS

use Net::SPDY::Framer;

my $framer = new Net::SPDY::Framer ({
    compressor => new Net::SPDY::Compressor,
    socket => $socket,
});

$framer->write_frame(
      type => Net::SPDY::Framer::PING,
      data => 0x706c6c6d,
);
while (my %frame = $framer->read_frame) {
      last if $frame{control} and $frame{type} eq Net::SPDY::Framer::PING;
}

DESCRIPTION

Net::SPDY::Framer provides SPDY protocol access on top of a network socket. It serializes and deserializes packets as they are, without implementing any other logic. For session management, see Net::SPDY::Session.

CONSTANTS

For the actual values refer to the protocol specification.

Frame types

SYN_STREAM, SYN_REPLY, RST_STREAM, SETTINGS, PING, GOAWAY, HEADERS, WINDOW_UPDATE, CREDENTIAL.

Frame flags

FLAG_FIN, FLAG_UNIDIRECTIONAL, FLAG_SETTINGS_CLEAR_SETTINGS.

SETTINGS flags

FLAG_SETTINGS_PERSIST_VALUE, FLAG_SETTINGS_PERSISTED.

SETTINGS values

SETTINGS_UPLOAD_BANDWIDTH, SETTINGS_DOWNLOAD_BANDWIDTH, SETTINGS_ROUND_TRIP_TIME, SETTINGS_MAX_CONCURRENT_STREAMS, SETTINGS_CURRENT_CWND, SETTINGS_DOWNLOAD_RETRANS_RATE, SETTINGS_INITIAL_WINDOW_SIZE, SETTINGS_CLIENT_CERTIFICATE_VECTOR_SIZE.

PROPERTIES

compressor

Net::SPDY::Compressor object representing the Zlib streams (one in each direction) used by the framer.

socket

IO::Handle instance that is used for actual network communication.

FRAME FORMATS

These are the data structures that are consumed by write_frame() and produced by read_frame() methods. Their purpose is to coveniently represent the fields of serialized SPDY frames. Please refer to the protocol specification ("SEE ALSO" section) for descriptions of the actual fields.

Not all fields are mandatory at all occassions. Serializer may assume sane values for certain fields, that are marked as Input only below, or provided with defaults.

SYN_STREAM
(
    # Common to control frames
    control     => 1,           # Input only
    version     => 3,           # Input only
    type        => Net::SPDY::Framer::SYN_STREAM,
    flags       => <flags>,     # Defaults to 0
    length      => <length>,    # Input only

    # Specific for SYN_STREAM
    stream_id   => <stream_id>,
    associated_stream_id => <associated_stream_id>,

    priority    => <priority>,
    slot        => <slot>,

    headers     =>  [
        ':version'  => <version>,   # E.g. 'HTTP/1.1'
        ':scheme'   => <scheme>,    # E.g. 'https'
        ':host'     => <host>,      # E.g. 'example.net:443',
        ':method'   => <method>,    # E.g. 'GET', 'HEAD',...
        ':path'     => <path>,      # E.g. '/something',
        ... # HTTP headers, e.g. Accept => 'text/plain'
    ],
)
SYN_REPLY
(
    # Common to control frames
    control     => 1,           # Input only
    version     => 3,           # Input only
    type        => Net::SPDY::Framer::SYN_REPLY,
    flags       => <flags>,     # Defaults to 0
    length      => <length>,    # Input only

    # Specific for SYN_REPLY
    stream_id   => <stream_id>,

    headers     =>  [
        ':version'  => <version>,   # E.g. 'HTTP/1.1'
        ':status'   => <status>,    # E.g. '500 Front Fell Off',
        ... # HTTP headers, e.g. 'Content-Type' => 'text/plain'
    ],
)
RST_STREAM
(
    # Common to control frames
    control     => 1,           # Input only
    version     => 3,           # Input only
    type        => Net::SPDY::Framer::RST_STREAM
    flags       => <flags>,     # Defaults to 0
    length      => <length>,    # Input only

    # Specific for RST_STREAM
    stream_id   => <stream_id>,
    status      => <status>,
)
SETTINGS
(
    # Common to control frames
    control     => 1,           # Input only
    version     => 3,           # Input only
    type        => Net::SPDY::Framer::SYN_SETTINGS
    flags       => <flags>,     # Defaults to 0
    length      => <length>,    # Input only

    # Specific for SETTINGS
    entries     => <entries>,   # Input only

    id_values   =>  [
        {
            flags   => <flags>,
            id  => <id>,
            value   => <value>,
        },
        ...
    ],
)
PING
(
    # Common to control frames
    control     => 1,           # Input only
    version     => 3,           # Input only
    type        => Net::SPDY::Framer::PING
    flags       => <flags>,     # Defaults to 0
    length      => <length>,    # Input only

    # Specific for PING
    id          => <id>,        # E.g. 0x706c6c6d
)
GOAWAY
(
    # Common to control frames
    control     => 1,           # Input only
    version     => 3,           # Input only
    type        => Net::SPDY::Framer::GOAWAY
    flags       => <flags>,     # Defaults to 0
    length      => <length>,    # Input only

    # Specific for GOAWAY
    last_good_stream_id => <last_good_stream_id>,
    status      => <status>,
)
HEADERS
(
    # Common to control frames
    control     => 1,           # Input only
    version     => 3,           # Input only
    type        => Net::SPDY::Framer::HEADERS,
    flags       => <flags>,     # Defaults to 0
    length      => <length>,    # Input only

    # Specific for HEADERS
    stream_id   => <stream_id>,

    headers     =>  [
        ... # HTTP headers, e.g. Accept => 'text/plain'
    ],
)
WINDOW_UPDATE
(
    # Common to control frames
    control     => 1,           # Input only
    version     => 3,           # Input only
    type        => Net::SPDY::Framer::WINDOW_UPDATE
    flags       => <flags>,     # Defaults to 0
    length      => <length>,    # Input only

    # Specific for WINDOW_UPDATE
    stream_id   => <stream_id>,
    delta_window_size => <delta_window_size>,
)
CREDENTIAL
(
    # Common to control frames
    control     => 1,           # Input only
    version     => 1,           # Input only
    type        => Net::SPDY::Framer::CREDENTIAL
    flags       => <flags>,     # Defaults to 0
    length      => <length>,    # Input only

    # Specific for CREDENTIAL
    slot        => <slot>,
    proof       => <proof>,
    certificates => [ <certificate>, ... ],
)

METHODS

new { socket => SOCKET, compressor => COMPRESSOR }

Creates a new framer instance. You need to create and pass both the socket for the network communication and the compressor instance.

write_frame FRAME

Serializes frame and writes it to the network socket.

read_frame

Reads frame from the network socket and returns it deserialized.

SEE ALSO

CONTRIBUTING

Source code for Net::SPDY is kept in a public GIT repository. Visit https://github.com/lkundrak/net-spdy.

Bugs reports and feature enhancement requests are tracked at https://rt.cpan.org/Public/Dist/Display.html?Name=Net::SPDY.

COPYRIGHT

Copyright 2012, Lubomir Rintel

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Lubomir Rintel lkundrak@v3.sk