Skip to content

Commit

Permalink
[TCN-840] - Add Connect Protocol Version Header (#370)
Browse files Browse the repository at this point in the history
* Add connect protocol version header to connect transport

* Uppercase header name
  • Loading branch information
gilwong00 authored Jan 6, 2023
1 parent 9d70251 commit d6598c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import { MethodKind } from "@bufbuild/protobuf";

const protocolVersion = "1";

/**
* Creates headers for a Connect request.
*/
Expand All @@ -33,5 +35,6 @@ export function connectCreateRequestHeader(
if (timeoutMs !== undefined) {
result.set("Connect-Timeout-Ms", `${timeoutMs}`);
}
result.set("Connect-Protocol-Version", protocolVersion);
return result;
}
2 changes: 2 additions & 0 deletions packages/connect-web/src/connect-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ function createConnectRequestHeaders(
methodKind: MethodKind,
useBinaryFormat: boolean
): Headers {
const protocolVersion = "1";
const result = new Headers(headers ?? {});
let type = "application/";
if (methodKind != MethodKind.Unary) {
Expand All @@ -381,6 +382,7 @@ function createConnectRequestHeaders(
if (timeoutMs !== undefined) {
result.set("Connect-Timeout-Ms", `${timeoutMs}`);
}
result.set("Connect-Protocol-Version", protocolVersion);
return result;
}

Expand Down

0 comments on commit d6598c5

Please sign in to comment.