-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Core - Add build information to all requests sent by HTTPClient as headers #5238
Core - Add build information to all requests sent by HTTPClient as headers #5238
Conversation
Here's a sample of the headers sent for each request, per the mock server tests: Relevant portions: We can update these header names or which values are used (as well as where they're placed and how, but I think Probably using the short version of The headers can technically be overridden via the config
|
String.format("header.%s", HTTPClientFactory.CLIENT_GIT_COMMIT_SHORT_HEADER), IcebergBuild.gitCommitShortId(), | ||
String.format("header.%s", HTTPClientFactory.CLIENT_VERSION_HEADER), IcebergBuild.version())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These don't really need to be set because HTTPClientFactory
isn't used here - the underlying JDBC client is what builds this.
We can however still override the version etc by sending back a configuration property of header.X-Client-Version
with the desired value to be used as the value (though I don't see any reason to do that).
.withHeader(HTTPClientFactory.CLIENT_VERSION_HEADER, icebergBuildFullVersion) | ||
.withHeader(HTTPClientFactory.CLIENT_GIT_COMMIT_SHORT_HEADER, icebergBuildGitCommitShort); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We add the headers that we expect to see as assertions on the mock request. The actual HTTPClient
is used, generated by the HTTPClientFactory
, which injects the headers.
If requests are not generated which have these headers, they will not match and the assertion of this mock request will fail.
Notice that we didn't have to add the request headers anywhere else (like we do with Authorization
elsewhere in this test suite when generating the actual requests on the updated line 205). That signifies that the headers are added automatically if the HTTPClient
is created via HTTPClientFactory
.
b90e54b
to
55ff696
Compare
Thanks, @kbendick! |
The HTTPClientFactory is used to build the HTTP Client that will be used by the REST Catalog.
This PR injects the following two headers into each request, for debugging purposes:
To test for these headers,
TestHTTPClient
was updated to use theHTTPClientFactory
. The headers, with their expected values, are placed on each expected request, which is an assertion.Notice that we don't have to add the headers onto the request that is sent, as they are default headers for each request.
This PR needs relies on work in #5237 and needs to be rebased once that is merged.