Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ytkang/http2ServerClient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

2 Commits

Repository files navigation

Golang http/2 (H2C) server client example

H2C is http/2 golang library without tls. In this example, the server can handle http/2 with http/1.1 requests

Server

h2s := &http2.Server{}
mux := NewMultiplexer()
mux.HandleFunc("/test", TestRequestHandler)
server := &http.Server{
 Addr: "0.0.0.0:9998",
 Handler: h2c.NewHandler(mux.Handler, h2s),
}
fmt.Printf("Listening [0.0.0.0:9998]...\n")
checkErr(server.ListenAndServe(), "while listening")

Build

go build -o server ./http2Server

Client

host := "127.0.0.1:9998"
// http2 request
client := NewClient()
sendHttp2Requeest(client, host, "/test", "YT")
sendHttp2Requeest(client, host, "/test", "SJ")
sendHttp2Requeest(client, host, "/test", "JH")
// http1.1 request
sendHttp1Request(host, "/test", "GOGO")

Build

go build -o client ./http2Client

Protocol

easyjson --all ./http2Protocol/protocol.go

About

Example of golang http2 server/client without TLS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /