h2c

package
v0.56.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: BSD-3-Clause Imports: 14 Imported by: 2,033

Documentation

Overview

Package h2c is deprecated.

This package used to support unencrypted HTTP/2. Unencrypted HTTP/2 is now supported directly by the net/http package.

To start a server with unencrypted HTTP/2 support:

srv := &http.Server{Addr: address}
srv.Protocols = new(http.Protocols)
srv.Protocols.SetHTTP1(true)
srv.Protocols.SetUnencryptedHTTP2(true)
srv.ListenAndServe()

To use HTTP/2 for unencrypted client requests:

tr := &http.Transport{}
tr.Protocols = new(http.Protocols)
tr.Protocols.SetUnencryptedHTTP2(true)
client := &http.Client{Transport: tr}

Deprecated: This package is deprecated.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler deprecated

func NewHandler(h http.Handler, s *http2.Server) http.Handler

NewHandler is deprecated.

Deprecated: Set the http.Server Protocols field to use unencrypted HTTP/2 instead.

Example
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
	fmt.Fprint(w, "Hello world")
})
h2s := &http2.Server{
	// ...
}
h1s := &http.Server{
	Addr:    ":8080",
	Handler: NewHandler(handler, h2s),
}
log.Fatal(h1s.ListenAndServe())

Types

This section is empty.

Jump to

Keyboard shortcuts

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