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

Add support for Connect-Protocol-Version header #520

Merged
merged 3 commits into from
Mar 8, 2023

Conversation

timostamm
Copy link
Member

@timostamm timostamm commented Mar 7, 2023

To allow for proxies to easily distinguish Connect RPC requests from other HTTP requests with the application/json content-type, we have introduced the Connect-Protocol-Version header.

Clients from this repository send this header along with every request since v0.6.0. connect-go supports the header since v1.4.0.

With this PR, servers can opt in to require this header with an option:

  /**
   * Require requests using the Connect protocol to include the header
   * Connect-Protocol-Version. This ensures that HTTP proxies and other
   * code inspecting traffic can easily identify Connect RPC requests,
   * even if they use a common Content-Type like application/json.
   *
   * If a Connect request does not include the Connect-Protocol-Version
   * header, an error with code invalid_argument (HTTP 400) is returned.
   * This option has no effect if the client uses the gRPC or the gRPC-web
   * protocol.
   */
  requireConnectProtocolHeader: boolean;

@timostamm timostamm force-pushed the tstamm/require-connect-protocol-version branch from 84269f7 to f4ff382 Compare March 8, 2023 08:24
@timostamm timostamm requested a review from smaye81 March 8, 2023 08:26
@bufdev
Copy link
Member

bufdev commented Mar 8, 2023

@akshayjshah just making sure we're on the same page - is this a new part of the connect protocol?

@akshayjshah
Copy link
Member

Yes. It lets middle boxes like Envoy reliably identify unary Connect requests. It's optional (for back-compat), but servers may reject requests without it and generated clients are encouraged to set it. From the protocol spec:

The Connect-Protocol-Version header distinguishes unary Connect RPC traffic from other requests that may use the same Content-Type. (In the future, it may also be used to support revisions to this protocol.) Clients, especially generated clients, should send this header. Servers and proxies may reject traffic without this header with an HTTP status code of 400.

@bufdev
Copy link
Member

bufdev commented Mar 8, 2023

Not so much for this PR, but will this be required? I assume it can't be since we hit v1.0

Edit: nevermind, finished reading your comment

@timostamm timostamm merged commit be84b78 into main Mar 8, 2023
@timostamm timostamm deleted the tstamm/require-connect-protocol-version branch March 8, 2023 18:30
This was referenced Mar 15, 2023
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.

4 participants