feat: add new Options to allow per method header values #2941
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add new "Option"s for those methods which already have option types to allow providing an ImmutableMap<String, String> to be applied as extra headers to all requests sent as part of that operation.
If an operation has multiple sources of input Options (rewrite) the "first" (i.e. source option) will be the one added to the request.
The following resources do not have "Option"s and therefor do not have extra headers support at this time:
Overview of the changes
This blind number of lines is large, but the number of differences is actually fairly low.
Headers
Opt` in UnifiedOpts, this is the primary guts of the new feature and is responsible for holding onto the extra header values and validating the provided headers to ensure no collisions with headers otherwise set by our library/restricted by gcs.extraHeaders
" to each of the 15 option classes along with accompanying javadocs. All javadocs are the exact same, and were copy-pasted for each method.Utils#headerNameToLowerCase
to centralize the logic for transforming header names across all locationsStorageRpc.Options#EXTRA_HEADERS
to support extra headers for JSON callsHttpStorageRpc
(433 lines),ApiaryUnbufferedReadableByteChannel
(13 lines) andJsonResumable*
(~45 lines + ~50 lines for existing tests) classes to takeEXTRA_HEADERS
into considerationITExtraHeadersOptionTest
to validate headers are properly added to each request of various operationsAssertRequestHeaders
which bothGrpcRequestAuditing
andRequestAuditing
now implement -- this interface makes it easy for each transport to share common methods for asserting request headers