h2c

command module
v0.0.0-...-b11a5d3 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

Cloud Run HTTP/2 Sample Server

This Go application serves requests using only the HTTP/2 cleartext (h2c) protocol (it does not support upgrading from HTTP/1.1).

It is provided for testing end-to-end HTTP/2 capabilities on Cloud Run.

Deploying to Cloud Run

Click this button:

Run on Google Cloud

Alternatively, you can use the gcloud SDK:

git clone https://github.com/GoogleCloudPlatform/golang-samples.git
cd ./golang-samples/run/h2c
gcloud beta run deploy http2-test --use-http2 --source=.

Cleanup: Remove the http2-test Service you deployed from Cloud Run using the Cloud Console.

Testing locally

  1. Check out this repository and navigate to this directory

  2. Start the server locally:

    go run .
    

Verifying h2c

  1. After the server starts, make a request using curl and use --http2-prior-knowledge to prevent upgrading from HTTP/1.1 (which is intentionally not supported by this program).

    curl -v --http2-prior-knowledge localhost:8080
    

    Note: If you have deployed on Cloud Run, you can replace localhost:8080 with your Cloud Run service URL.

  2. The curl output should indicate HTTP/2 is used:

    < HTTP/2 200
    < content-type: text/plain; charset=utf-8
    < content-length: 32
    < date: Fri, 08 Jan 2021 18:13:06 GMT
    
    This request is served over HTTP/2.0 protocol!
    

Since this server intentionally doesn't support upgrading from HTTP/1.1, performing the same query without the --http2-prior-knowledge option makes curl to use HTTP/1, which fails as expected.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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