grpc / grpc/grpc-dotnet

What is the best practice for response meta-data when using interceptors?

Open
#2,346 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
C#
Stars
4.5k
Forks
836
Avg merge
6d 3h
Merged PRs (30d)
7

Description

I have a problem handling response meta data on the server side.

I would like to include some information in any response my server sends, so an interceptor came to mind.
But `WriteResponseHeadersAsync` can only be called once and thus using it within an interceptor forbids itself as it would be hard to document and makes using the method elsewhere impossible.
I can change the trailers of any response perfectly fine in interceptors and chain as many as I want, but if I want to write information to the header, there is no way.

why isn't the repsonse header handled the same as the trailer, or the client-sides headers? Have a Metadata-object within the context, anyone can change it and the underlying framework sends them when the actual response is send?

Contributor guide

Open the contributing guide

Research direction

Start by tracing server interceptor handling around WriteResponseHeadersAsync and compare it with trailer metadata and client-side headers. Determine whether the desired response-header behavior requires a framework change or clearer guidance, then define the expected metadata lifecycle and validate it with an appropriate server-side scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.