From 90e0ea517a7ea78354947e05126f3f5206030807 Mon Sep 17 00:00:00 2001 From: Jose Ulises Nino Rivera Date: Wed, 16 Oct 2019 21:29:23 -0700 Subject: [PATCH] core: buffer body for retries (#511) Description: set stream options to buffer stream body for retries. Risk Level: med - the client now buffers stream body for retries. Testing: local - lyft and example apps. Signed-off-by: Jose Nino Signed-off-by: JP Simard --- mobile/library/common/http/dispatcher.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mobile/library/common/http/dispatcher.cc b/mobile/library/common/http/dispatcher.cc index d822ea92a91d..94e4572c5701 100644 --- a/mobile/library/common/http/dispatcher.cc +++ b/mobile/library/common/http/dispatcher.cc @@ -148,7 +148,14 @@ envoy_status_t Dispatcher::startStream(envoy_stream_t new_stream_handle, std::make_unique(new_stream_handle, bridge_callbacks, *this); AsyncClient& async_client = getClient(); - AsyncClient::Stream* underlying_stream = async_client.start(*callbacks, {}); + // Note: currently all streams are set to buffer body data for retries. + // This is done as an assumption that almost all client calls are retriable, + // and the penalty for those that are not is minimal. + // The stream options could be exposed + // (like in: https://github.com/lyft/envoy-mobile/pull/456/) in the future, + // if the library needs the added configuration flexiblity. + AsyncClient::Stream* underlying_stream = + async_client.start(*callbacks, AsyncClient::StreamOptions().setBufferBodyForRetry(true)); if (!underlying_stream) { // TODO: this callback might fire before the startStream function returns.