Documentation ¶
Index ¶
- Constants
- Variables
- func MirrorStreamHandler(stream *Stream)
- func NoOpStreamHandler(stream *Stream)
- type AuthHandler
- type Connection
- func (s *Connection) Close() error
- func (s *Connection) CloseChan() <-chan bool
- func (s *Connection) CloseWait() error
- func (s *Connection) CreateStream(headers http.Header, parent *Stream, fin bool) (*Stream, error)
- func (s *Connection) FindStream(streamId uint32) *Stream
- func (s *Connection) NotifyClose(c chan<- *Stream, timeout time.Duration)
- func (s *Connection) PeekNextStreamId() spdy.StreamId
- func (s *Connection) Ping() (time.Duration, error)
- func (s *Connection) Serve(newHandler StreamHandler)
- func (s *Connection) SetCloseTimeout(timeout time.Duration)
- func (s *Connection) SetIdleTimeout(timeout time.Duration)
- func (s *Connection) Wait(waitTimeout time.Duration) error
- type PriorityFrameQueue
- type Stream
- func (s *Stream) Cancel() error
- func (s *Stream) Close() error
- func (s *Stream) CreateSubStream(headers http.Header, fin bool) (*Stream, error)
- func (s *Stream) Headers() http.Header
- func (s *Stream) Identifier() uint32
- func (s *Stream) IsFinished() bool
- func (s *Stream) LocalAddr() net.Addr
- func (s *Stream) Parent() *Stream
- func (s *Stream) Read(p []byte) (n int, err error)
- func (s *Stream) ReadData() ([]byte, error)
- func (s *Stream) ReceiveHeader() (http.Header, error)
- func (s *Stream) Refuse() error
- func (s *Stream) RemoteAddr() net.Addr
- func (s *Stream) Reset() error
- func (s *Stream) SendHeader(headers http.Header, fin bool) error
- func (s *Stream) SendReply(headers http.Header, fin bool) error
- func (s *Stream) SetDeadline(t time.Time) error
- func (s *Stream) SetPriority(priority uint8)
- func (s *Stream) SetReadDeadline(t time.Time) error
- func (s *Stream) SetWriteDeadline(t time.Time) error
- func (s *Stream) String() string
- func (s *Stream) Wait() error
- func (s *Stream) WaitTimeout(timeout time.Duration) error
- func (s *Stream) Write(data []byte) (n int, err error)
- func (s *Stream) WriteData(data []byte, fin bool) error
- type StreamHandler
Constants ¶
const ( FRAME_WORKERS = 5 QUEUE_SIZE = 50 )
Variables ¶
var ( ErrInvalidStreamId = errors.New("Invalid stream id") ErrTimeout = errors.New("Timeout occured") ErrReset = errors.New("Stream reset") ErrWriteClosedStream = errors.New("Write on closed stream") )
var (
DEBUG = os.Getenv("DEBUG")
)
var (
ErrUnreadPartialData = errors.New("unread partial data")
)
Functions ¶
func MirrorStreamHandler ¶
func MirrorStreamHandler(stream *Stream)
MirrorStreamHandler mirrors all streams.
func NoOpStreamHandler ¶
func NoOpStreamHandler(stream *Stream)
NoopStreamHandler does nothing when stream connects, most likely used with RejectAuthHandler which will not allow any streams to make it to the stream handler.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func NewConnection ¶
func NewConnection(conn net.Conn, server bool) (*Connection, error)
NewConnection creates a new spdy connection from an existing network connection.
func (*Connection) Close ¶
func (s *Connection) Close() error
Closes spdy connection by sending GoAway frame and initiating shutdown
func (*Connection) CloseChan ¶
func (s *Connection) CloseChan() <-chan bool
func (*Connection) CloseWait ¶
func (s *Connection) CloseWait() error
CloseWait closes the connection and waits for shutdown to finish. Note the underlying network Connection is not closed until the end of shutdown.
func (*Connection) CreateStream ¶
CreateStream creates a new spdy stream using the parameters for creating the stream frame. The stream frame will be sent upon calling this function, however this function does not wait for the reply frame. If waiting for the reply is desired, use the stream Wait or WaitTimeout function on the stream returned by this function.
func (*Connection) FindStream ¶
func (s *Connection) FindStream(streamId uint32) *Stream
FindStream looks up the given stream id and either waits for the stream to be found or returns nil if the stream id is no longer valid.
func (*Connection) NotifyClose ¶
func (s *Connection) NotifyClose(c chan<- *Stream, timeout time.Duration)
NotifyClose registers a channel to be called when the remote peer inidicates connection closure. The last stream to be received by the remote will be sent on the channel. The notify timeout will determine the duration between go away received and the connection being closed.
func (*Connection) PeekNextStreamId ¶
func (s *Connection) PeekNextStreamId() spdy.StreamId
PeekNextStreamId returns the next sequential id and keeps the next id untouched
func (*Connection) Ping ¶
func (s *Connection) Ping() (time.Duration, error)
Ping sends a ping frame across the connection and returns the response time
func (*Connection) Serve ¶
func (s *Connection) Serve(newHandler StreamHandler)
Serve handles frames sent from the server, including reply frames which are needed to fully initiate connections. Both clients and servers should call Serve in a separate goroutine before creating streams.
func (*Connection) SetCloseTimeout ¶
func (s *Connection) SetCloseTimeout(timeout time.Duration)
SetCloseTimeout sets the amount of time close will wait for streams to finish before terminating the underlying network connection. Setting the timeout to 0 will cause close to wait forever, which is the default.
func (*Connection) SetIdleTimeout ¶
func (s *Connection) SetIdleTimeout(timeout time.Duration)
SetIdleTimeout sets the amount of time the connection may sit idle before it is forcefully terminated.
func (*Connection) Wait ¶
func (s *Connection) Wait(waitTimeout time.Duration) error
Wait waits for the connection to finish shutdown or for the wait timeout duration to expire. This needs to be called either after Close has been called or the GOAWAYFRAME has been received. If the wait timeout is 0, this function will block until shutdown finishes. If wait is never called and a shutdown error occurs, that error will be logged as an unhandled error.
type PriorityFrameQueue ¶
type PriorityFrameQueue struct {
// contains filtered or unexported fields
}
func NewPriorityFrameQueue ¶
func NewPriorityFrameQueue(size int) *PriorityFrameQueue
func (*PriorityFrameQueue) Drain ¶
func (q *PriorityFrameQueue) Drain()
func (*PriorityFrameQueue) Pop ¶
func (q *PriorityFrameQueue) Pop() spdy.Frame
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
func (*Stream) Cancel ¶
Cancel sends a reset frame with the status canceled. This can be used at any time by the creator of the Stream to indicate the stream is no longer needed.
func (*Stream) Close ¶
Close closes the stream by sending an empty data frame with the finish flag set, indicating this side is finished with the stream.
func (*Stream) CreateSubStream ¶
CreateSubStream creates a stream using the current as the parent
func (*Stream) Identifier ¶
Identifier returns a 32 bit identifier for the stream
func (*Stream) IsFinished ¶
IsFinished returns whether the stream has finished sending data
func (*Stream) Read ¶
Read reads bytes from a stream, a single read will never get more than what is sent on a single data frame, but a multiple calls to read may get data from the same data frame.
func (*Stream) ReadData ¶
ReadData reads an entire data frame and returns the byte array from the data frame. If there is unread data from the result of a Read call, this function will return an ErrUnreadPartialData.
func (*Stream) ReceiveHeader ¶
ReceiveHeader receives a header sent on the other side of the stream. This function will block until a header is received or stream is closed.
func (*Stream) Refuse ¶
Refuse sends a reset frame with the status refuse, only valid to be called once when handling a new stream. This may be used to indicate that a stream is not allowed when http status codes are not being used.
func (*Stream) RemoteAddr ¶
func (*Stream) SendHeader ¶
SendHeader sends a header frame across the stream
func (*Stream) SendReply ¶
SendReply sends a reply on a stream, only valid to be called once when handling a new stream
func (*Stream) SetPriority ¶
SetPriority sets the stream priority, does not affect the remote priority of this stream after Open has been called. Valid values are 0 through 7, 0 being the highest priority and 7 the lowest.
func (*Stream) String ¶
String returns the string version of stream using the streamId to uniquely identify the stream
func (*Stream) WaitTimeout ¶
WaitTimeout waits for the stream to receive a reply or for timeout. When the timeout is reached, ErrTimeout will be returned.
type StreamHandler ¶
type StreamHandler func(stream *Stream)
Directories ¶
Path | Synopsis |
---|---|
Package spdy implements the SPDY protocol (currently SPDY/3), described in http://www.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3.
|
Package spdy implements the SPDY protocol (currently SPDY/3), described in http://www.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3. |