Skip to content

[C++][Flight RPC] ServerMiddleware::SendingHeaders called before RPC handler, not "when sending headers" #39791

@indigophox

Description

@indigophox

Describe the bug, including details regarding any error messages, version, and platform.

The expected behaviour here is as e.g. the Java implementation does things and the docs imply: SendingHeaders is called when headers are to be sent, i.e. after an RPC handler has had a chance to interact with a call-local server middleware instance.

However, in the C++ implementation this is instead called while the call context is being constructed:

instance->SendingHeaders(&outgoing_headers);

Ideally this should be called during (voluntarily by the RPC handler code, possibly, but that introduces the difficult case where a handler has not triggered header ingestion from middleware and this must be detected etc.

Blocking handlers are simple enough to rectify this for, but streaming handlers (both e.g. DoAction and to a greater extend things like DoGet/DoExchange) present an issue as the header ingestion cannot be triggered after the handler has run as it must happen before streaming to the client commences. I believe the simplest and cleanest solution here is to introduce a shim around the transport-layer result stream listener that fires a one-time callback to handle the header ingestion then unblocks sync and async calls to the listener's on*() callbacks.

The suggested solution is a slight breaking change, but by-and-large it would only break an implementation that assumed that altering C++ middleware would have no further effect on that call's response headers but did so anyways (and then that started working as it should).

Component(s)

C++, FlightRPC

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions