GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: add new Options to allow per method header values by BenWhitehead · Pull Request #2941 · googleapis/java-storage

This repository was archived by the owner on Sep 25, 2026. It is now read-only.

Conversation

@BenWhitehead

@BenWhitehead BenWhitehead commented Feb 19, 2025

Copy link
Copy Markdown
Collaborator

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:

  • Acl
  • DefaultAcl
  • ServiceAccount
  • Notification

Overview of the changes

This blind number of lines is large, but the number of differences is actually fairly low.

  • Add 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.
  • The ~800 lines of change in Storage.java are the same "add new option 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.
  • Create new utility method Utils#headerNameToLowerCase to centralize the logic for transforming header names across all locations
  • Add new StorageRpc.Options#EXTRA_HEADERS to support extra headers for JSON calls
    • update JSON request building code in HttpStorageRpc (433 lines), ApiaryUnbufferedReadableByteChannel (13 lines) and JsonResumable* (~45 lines + ~50 lines for existing tests) classes to take EXTRA_HEADERS into consideration
  • test: add new suite of tests ITExtraHeadersOptionTest to validate headers are properly added to each request of various operations
  • test: introduce new interface AssertRequestHeaders which both GrpcRequestAuditing and RequestAuditing now implement -- this interface makes it easy for each transport to share common methods for asserting request headers

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@BenWhitehead
feat: add new Options to allow per method header values
b1972d5
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:
* Acl
* DefaultAcl
* ServiceAccount
* Notification
@BenWhitehead
BenWhitehead requested a review from a team February 19, 2025 19:35
@product-auto-label product-auto-label Bot added size: xl Pull request size is extra large. api: storage Issues related to the googleapis/java-storage API. labels Feb 19, 2025
BenWhitehead added 2 commits February 19, 2025 17:48
@BenWhitehead
chore: fix npe
b23cd05
@BenWhitehead
chore: fix npe -- again
e949ace
ddelgrosso1
ddelgrosso1 reviewed Feb 25, 2025
View reviewed changes
Comment thread google-cloud-storage/src/main/java/com/google/cloud/storage/UnifiedOpts.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

ddelgrosso1
ddelgrosso1 approved these changes Feb 25, 2025
View reviewed changes

@ddelgrosso1 ddelgrosso1 left a comment

Copy link
Copy Markdown
Contributor

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.

I'm not a java expert but LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@BenWhitehead
chore: fix comment wrap weirdness
99f3c32
@BenWhitehead BenWhitehead mentioned this pull request Feb 25, 2025
Expose an API to get Resumable Upload Session URL #2903
Closed
@BenWhitehead
BenWhitehead merged commit 297802d into main Feb 25, 2025
@BenWhitehead
BenWhitehead deleted the extra-headers branch February 25, 2025 18:50
@release-please release-please Bot mentioned this pull request Feb 25, 2025
chore(main): release 2.49.0 #2931
Merged
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

1 more reviewer
@ddelgrosso1 ddelgrosso1 ddelgrosso1 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

api: storage Issues related to the googleapis/java-storage API. size: xl Pull request size is extra large.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@BenWhitehead @ddelgrosso1
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.