1
0
mirror of https://github.com/ceph/ceph-csi.git synced 2024-12-30 00:40:21 +00:00
ceph-csi/vendor/github.com/moby/spdystream
Madhu Rajanna 5a66991bb3 rebase: update kubernetes to latest
updating the kubernetes release to the
latest in main go.mod

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2024-08-20 08:17:01 +00:00
..
spdy rebase: update kubernetes to v1.21.2 2021-07-01 03:35:23 +00:00
connection.go rebase: update kubernetes to latest 2024-08-20 08:17:01 +00:00
CONTRIBUTING.md rebase: update kubernetes to v1.21.2 2021-07-01 03:35:23 +00:00
handlers.go rebase: update kubernetes to v1.21.2 2021-07-01 03:35:23 +00:00
LICENSE rebase: update kubernetes to v1.21.2 2021-07-01 03:35:23 +00:00
MAINTAINERS rebase: update kubernetes to v1.21.2 2021-07-01 03:35:23 +00:00
NOTICE rebase: update kubernetes to v1.21.2 2021-07-01 03:35:23 +00:00
priority.go rebase: update kubernetes to v1.21.2 2021-07-01 03:35:23 +00:00
README.md rebase: update kubernetes to v1.21.2 2021-07-01 03:35:23 +00:00
stream.go rebase: update kubernetes to latest 2024-08-20 08:17:01 +00:00
utils.go rebase: update kubernetes to v1.21.2 2021-07-01 03:35:23 +00:00

SpdyStream

A multiplexed stream library using spdy

Usage

Client example (connecting to mirroring server without auth)

package main

import (
	"fmt"
	"github.com/moby/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/moby/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 2013-2021 Docker, inc. Released under the Apache 2.0 license.