automation-tests/vendor/github.com/docker/spdystream
Daniel J Walsh 68c313911e
Update vendor of buildah and containers/common
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-02-25 07:46:20 -04:00
..
spdy Initial checkin from CRI-O repo 2017-11-01 11:24:59 -04:00
CONTRIBUTING.md migrate to go-modules 2019-06-24 13:20:59 +02:00
LICENSE Initial checkin from CRI-O repo 2017-11-01 11:24:59 -04:00
LICENSE.docs Initial checkin from CRI-O repo 2017-11-01 11:24:59 -04:00
MAINTAINERS migrate to go-modules 2019-06-24 13:20:59 +02:00
README.md Initial checkin from CRI-O repo 2017-11-01 11:24:59 -04:00
connection.go Update vendor of buildah and containers/common 2020-02-25 07:46:20 -04:00
handlers.go Update vendor of buildah and containers/common 2020-02-25 07:46:20 -04:00
priority.go Initial checkin from CRI-O repo 2017-11-01 11:24:59 -04:00
stream.go Initial checkin from CRI-O repo 2017-11-01 11:24:59 -04:00
utils.go Initial checkin from CRI-O repo 2017-11-01 11:24:59 -04:00

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 © 2014-2015 Docker, Inc. All rights reserved, except as follows. Code is released under the Apache 2.0 license. The README.md file, and files in the "docs" folder are licensed under the Creative Commons Attribution 4.0 International License under the terms and conditions set forth in the file "LICENSE.docs". You may obtain a duplicate copy of the same license, titled CC-BY-SA-4.0, at http://creativecommons.org/licenses/by/4.0/.