This repository was archived by the owner on Mar 26, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 80
fix: add field headers for other http verbs #443
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5bb7d30
fix: add field headers for other http verbs
busunkim96 6c8aeeb
Merge branch 'master' into field-headers
busunkim96 797da8f
fix: fix custom path
busunkim96 78359ca
Merge branch 'field-headers' of github.com:googleapis/gapic-generator…
busunkim96 85ca6c9
fix: consolidate into one test
busunkim96 f569911
Merge branch 'master' into field-headers
busunkim96 224d81a
Merge branch 'master' into field-headers
busunkim96 38e8711
test: update generated unit tests
busunkim96 afd742a
test: update ads template
busunkim96 85f9699
fix: don't add field headers to streaming methods
busunkim96 8ed787d
test: exclude header check for client streaming method
busunkim96 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -258,25 +258,33 @@ def test_{{ method.name|snake_case }}(transport: str = 'grpc'): | |
| {% endfor %} | ||
| {% endif %} | ||
|
|
||
| {% if method.field_headers %} | ||
| {% if method.field_headers and not method.client_streaming %} | ||
| def test_{{ method.name|snake_case }}_field_headers(): | ||
| client = {{ service.client_name }}( | ||
| credentials=credentials.AnonymousCredentials(), | ||
| ) | ||
| ) | ||
|
|
||
| # Any value that is part of the HTTP/1.1 URI should be sent as | ||
| # a field header. Set these to a non-empty value. | ||
| request = {{ method.input.ident }}( | ||
| {%- for field_header in method.field_headers %} | ||
| {{ field_header }}='{{ field_header }}/value', | ||
| {%- endfor %} | ||
| ) | ||
| request = {{ method.input.ident }}() | ||
|
|
||
| {%- for field_header in method.field_headers %} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tweaking this slightly for field headers like |
||
| request.{{ field_header }} = '{{ field_header }}/value' | ||
| {%- endfor %} | ||
|
|
||
| # Mock the actual call within the gRPC stub, and fake the request. | ||
| with mock.patch.object( | ||
| type(client._transport.{{ method.name|snake_case }}), | ||
| '__call__') as call: | ||
| {% if method.void -%} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copy-pasted from the unit test below this. |
||
| call.return_value = None | ||
| {% elif method.lro -%} | ||
| call.return_value = operations_pb2.Operation(name='operations/op') | ||
| {% elif method.server_streaming -%} | ||
| call.return_value = iter([{{ method.output.ident }}()]) | ||
| {% else -%} | ||
| call.return_value = {{ method.output.ident }}() | ||
| {% endif %} | ||
| client.{{ method.name|snake_case }}(request) | ||
|
|
||
| # Establish that the underlying gRPC stub method was called. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
Added this for a failing showcase test (see streaming method in proto and failing test).
Not sure if this is the right call though. What's the correct way to handle metadata/headers for streaming methods? @software-dov
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 was under the impression that headers for streaming methods don't make a lot of sense because they're not tightly bound to http semantics. If that's not correct, then I think we would need to ask someone who knows better.