h2c

package module
v0.0.0-...-44430fb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2017 License: Apache-2.0 Imports: 8 Imported by: 2

README

h2c

HTTP/2 Cleartext Wrappers

$ go get github.com/carl-mastrangelo/h2c

By default, the Go HTTP Server only handles HTTP/2 connections over TLS as hinted by RFC 7540. This is good for the security of the Internet, but makes things cumbersome when proxying requests over an already secure connection (such as in-memory unit tests, Unix Domain Sockets, local TCP connections, etc.).

The h2c package wraps an existing http.Server's Handler in such a way that incoming cleartext requests are rewritten to be handled by the given HTTP/2 Server. For example:

	s := &http.Server{
		    Handler: grpc.NewServer(),
	}
	
	h2c.AttachClearTextHandler(nil /* default http2 server */, s)
	
	s.ListenAndServe()

For clients:

	c := &http.Client{}
	h2c.AttachClearTextUpgrade(c)

	resp, err := c.Get("http://localhost:8080/")

Documentation

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL