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

ProcessingRequest.Builder creating a request with both headers and body #37939

Open
yoav-sentinel opened this issue Jan 9, 2025 · 1 comment
Labels
area/ext_proc question Questions that are neither investigations, bugs, nor enhancements

Comments

@yoav-sentinel
Copy link

yoav-sentinel commented Jan 9, 2025

Title: Create a ProcessingRequest that has both headers and body

Description:
I have an external processor service and in my tests I'm creating a ProcessingRequest to be sent to it, to test my external processing logic.

I'm now trying to create a ProcessingRequest entity with headers and body, while it seems the ProcessingRequest.Builder is using a disjoint case-based approach (requestCase_).

    private static ProcessingRequest addRequestBody(HttpHeaders headers, HttpBody body) {
        return ProcessingRequest.newBuilder()
                .setRequestHeaders(headers)
                .setRequestBody(body)
                .build();
    }

// Returned request:
// request_body {
//   body: "{\"key\": \"value\"}"
// }

Therefore, the setRequestHeaders returns a Builder just for headers (requestCase_ = 2), and then setRequestBody replaces the earlier with a new Builder just for body (requestCase_ = 4).

Am I missing something? Or it is not supported to create a request with more than one case?

@yoav-sentinel yoav-sentinel added the triage Issue requires triage label Jan 9, 2025
@zuercher zuercher added question Questions that are neither investigations, bugs, nor enhancements area/ext_proc and removed triage Issue requires triage labels Jan 9, 2025
@zuercher
Copy link
Member

zuercher commented Jan 9, 2025

Per the proto definition only one of request_headers or request_body may be set (among other fields).

I've not used the ext_proc filter myself, but the docs suggest to me that as envoy receives request headers, request body, request trailers, response headers, response body, or response_trailers it checks the filter configuration's processing_mode and may send a matching ProcessingRequest to the external processor service. To process request headers and request body, your service will need to handle two separate ProcessingMessage instances.

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

No branches or pull requests

2 participants