Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Go
branch: master
Failed to load latest commit information.
ws Expose a websocket implementing net.Conn
CONTRIBUTING.md Add maintainers, license, and contributing instructions
LICENSE Add maintainers, license, and contributing instructions
MAINTAINERS Add maintainers, license, and contributing instructions
README.md Update README as stream.Open() function was removed
connection.go Use github spdy repository
handlers.go Remove auth handler in favor of handling auth in stream handler
priority.go Use github spdy repository
priority_test.go Use github spdy repository
spdy_bench_test.go Use random ports in unit tests
spdy_test.go Don't try to read/write if connection is closed
stream.go
utils.go move logging to log, utils.go contains a debug logging function.

README.md

SpdyStream

A multiplexed stream library using spdy

Usage

Client example (connecting to mirroring server without auth)

package main

import (
    "fmt"
    "github.com/docker/spdystream"
    "net"
    "net/http"
)

func main() {
    conn, err := net.Dial("tcp", "localhost:8080")
    if err != nil {
        panic(err)
    }
    spdyConn, err := spdystream.NewConnection(conn, false)
    if err != nil {
        panic(err)
    }
    go spdyConn.Serve(spdystream.NoOpStreamHandler)
    stream, err := spdyConn.CreateStream(http.Header{}, nil, false)
    if err != nil {
        panic(err)
    }

    stream.Wait()

    fmt.Fprint(stream, "Writing to stream")

    buf := make([]byte, 25)
    stream.Read(buf)
    fmt.Println(string(buf))

    stream.Close()
}

Server example (mirroring server without auth)

package main

import (
    "github.com/docker/spdystream"
    "net"
)

func main() {
    listener, err := net.Listen("tcp", "localhost:8080")
    if err != nil {
        panic(err)
    }
    for {
        conn, err := listener.Accept()
        if err != nil {
            panic(err)
        }
        spdyConn, err := spdystream.NewConnection(conn, true)
        if err != nil {
            panic(err)
        }
        go spdyConn.Serve(spdystream.MirrorStreamHandler)
    }
}

Copyright and license

Code and documentation copyright 2013-2014 Docker, inc. Code released under the Apache 2.0 license. Docs released under Creative commons.

Something went wrong with that request. Please try again.