Repository navigation
Enable header modifications with body in "buffered" mode - #15935
Conversation
Commit message: Make it possible to process header mutations along with body mutations when the body is in "BUFFERED" mode. Additional description: This works by returning "StopIteration" after the headers have been processed until a response comes back from the "headers" message. The body is watermarked in the meantime. As a result, large bodies will still stream through without exceeding the buffer limit when the body mode is not "BUFFERED." Risk Level: Medium. Changes how bodies are handled. Testing: Existing unit and integration tests, plus some manual verification using external servers. Signed-off-by: Gregory Brail <[email protected]>
snowp
left a comment
There was a problem hiding this comment.
Thanks! Nice addition, left some comments to get you started
Signed-off-by: Gregory Brail <[email protected]>
Signed-off-by: Gregory Brail <[email protected]>
snowp
left a comment
There was a problem hiding this comment.
Thanks this looks pretty good, just one question
| // Otherwise, we're not ready to continue processing because then | ||
| // we won't be able to modify the headers any more, so do nothing and | ||
| // let the doData callback handle body chunks until the end is reached. | ||
| return true; |
There was a problem hiding this comment.
Hmm, shouldn't this be false to indicate that we did not process the message? I don't recall how this was in the previous iteration, but now it seems like we return true regardless of what body_send_deferred_ is set to?
Should there be a return after L42?
There was a problem hiding this comment.
The contract for this function, which is called from "onReceiveMessage" in ext_proc.cc, is that it returns false if the message is unexpected (aka spurious). So it's correct to return true in this case, and that's how it's worked for a long time.
In that particular case -- line 48 -- a "headers response" came back from the server in response to a previous headers request. The processor requested to buffer the body, but the entire body hadn't been received by the filter yet, which is why "body_send_deferred_" is false. The filter needs to continue buffering the body until the end of stream is reached, at which point it will send the body to the server. So yes, that's correct in this case.
There was a problem hiding this comment.
Got it! I saw
message_handled = decoding_state_.handleHeadersResponse(response->request_headers());
and it made me think that we were going to return false in this case since we hadn't been able to "handle" the response (due to the body not being fully buffered). Your explanation makes sense though, thanks for that!
…15935) This works by returning "StopIteration" after the headers have been processed until a response comes back from the "headers" message. The body is watermarked in the meantime. As a result, large bodies will still stream through without exceeding the buffer limit when the body mode is not "BUFFERED." Risk Level: Medium. Changes how bodies are handled. Testing: Existing unit and integration tests, plus some manual verification using external servers. Release Notes: Servers for the ext_proc filter can now use the HeaderMutation message when sending back a response to a request_body or response_body message to change headers at the same time as the body. This is only possible when the BodySendMode is BUFFERED. Signed-off-by: Gregory Brail <[email protected]> Signed-off-by: Gokul Nair <[email protected]>
Commit message: Make it possible to process header mutations
along with body mutations when the body is in "BUFFERED" mode.
Additional Description: This works by returning "StopIteration"
after the headers have been processed until a response comes
back from the "headers" message. The body is watermarked in the
meantime. As a result, large bodies will still stream through
without exceeding the buffer limit when the body mode is not
"BUFFERED."
Risk Level: Medium. Changes how bodies are handled.
Testing: Existing unit and integration tests, plus some
manual verification using external servers.
Release Notes: Servers for the ext_proc filter can now use the HeaderMutation message when sending back a response to a request_body or response_body message to change headers at the same time as the body. This is only possible when the BodySendMode is BUFFERED.
Signed-off-by: Gregory Brail [email protected]