Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to invoke decodeData in a header-only request? #36692

Open
Octopus409 opened this issue Oct 18, 2024 · 3 comments
Open

How to invoke decodeData in a header-only request? #36692

Octopus409 opened this issue Oct 18, 2024 · 3 comments
Labels
question Questions that are neither investigations, bugs, nor enhancements

Comments

@Octopus409
Copy link

Octopus409 commented Oct 18, 2024

I am writing a filter that can inject some data into body even it's a header-only request.
I have tried call addDecodedData in decodeHeader() to add some data, but decodeData() has not been called later in the same filter. It seems that this will only take effect in subsequent filters.

I try addDecodeData in decodeHeader() look like this.

if(end_stream){
    // for header-only request, add an empty body frame to trigger decodeData()
    Envoy::Buffer::OwnedImpl buffer{"mark"};
    decoder_callbacks_->addDecodedData(buffer, true);
}
return  Http::FilterHeadersStatus::StopIteration;

I'm not sure if my understanding of addDecodedData is correct. Maybe I should add data in the previous filter and then my custom filter will invoke decodeData? Is there any way to invoke decodeData in the same filter?

@Octopus409 Octopus409 added the triage Issue requires triage label Oct 18, 2024
@tyxia tyxia added question Questions that are neither investigations, bugs, nor enhancements and removed triage Issue requires triage labels Oct 18, 2024
@tyxia
Copy link
Member

tyxia commented Oct 18, 2024

decodeData by design is invoked for body. i.e., not for header only request

@Octopus409
Copy link
Author

decodeData by design is invoked for body. i.e., not for header only request

thanks for your comment, you are right, invoke decodeData in a header only request is bit weird.

virtual void addDecodedData(Buffer::Instance& data, bool streaming_filter) PURE;

but I found this note in the decoder callback, which seems to support this special requirement.

@tyxia
Copy link
Member

tyxia commented Oct 19, 2024

That is for subsequent filter not for the same filter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions that are neither investigations, bugs, nor enhancements
Projects
None yet
Development

No branches or pull requests

2 participants