Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify current state of HTTP/2 support #103

Merged
merged 2 commits into from
Oct 26, 2020
Merged

Conversation

ptone
Copy link
Collaborator

@ptone ptone commented Oct 26, 2020

No description provided.

@ahmetb
Copy link
Owner

ahmetb commented Oct 26, 2020

can you run npx markdown-toc -i README.md to update ToC?

README.md Outdated Show resolved Hide resolved
README.md Outdated
package to force your HTTP server to serve on `h2c`. (See [this StackOverflow
answer for
more](https://stackoverflow.com/questions/61231930/can-i-have-my-cloudrun-server-receive-http-2-requests)).
If you develop an app that **only** speaks HTTP/2 (with H2C), Cloud Run will
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "will not route" should be "will downgrade requests to HTTP/1".

H2C is designed to be compatible with HTTP1.

Copy link
Collaborator Author

@ptone ptone Oct 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can write a HTTP/2 only without downgrade, and require prior-knowledge - but this is in the weeds maybe:

// This server only supports "H2C prior knowledge".
// You can add standard HTTP/2 support by adding a TLS config.
func H2CServerPrior() {
	server := http2.Server{}

	l, err := net.Listen("tcp", "0.0.0.0:8080")
	checkErr(err, "while listening")

	fmt.Printf("Listening [0.0.0.0:8080]...\n")
	for {
		conn, err := l.Accept()
		checkErr(err, "during accept")

		server.ServeConn(conn, &http2.ServeConnOpts{
			Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
				fmt.Printf("New Connection: %+v\n", r)
				fmt.Fprintf(w, "Hello, %v, http: %v", r.URL.Path, r.TLS == nil)
			}),
		})
	}
}

@ahmetb ahmetb merged commit fe9e5c7 into ahmetb:master Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants