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

Fix a bug in HyperFeatureRequester::get_all() #65

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions launchdarkly-server-sdk/src/feature_requester.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::reqwest::is_http_error_recoverable;
use futures::future::BoxFuture;
use hyper::body::HttpBody;
use hyper::Body;
use std::collections::HashMap;
use std::sync::Arc;
Expand Down Expand Up @@ -77,7 +78,7 @@ where
.request(request_builder.body(Body::empty()).unwrap())
.await;

let response = match result {
let mut response = match result {
Ok(response) => response,
Err(e) => {
// It appears this type of error will not be an HTTP error.
Expand All @@ -101,15 +102,16 @@ where
.map_or_else(|_| "".into(), |s| s.into());

if response.status().is_success() {
let bytes = hyper::body::to_bytes(response.into_body())
.await
.map_err(|e| {
error!(
"An error occurred while reading the polling response body: {}",
e
);
FeatureRequesterError::Temporary
})?;
let mut bytes = Vec::new();
while let Some(chunk) = response.body_mut().data().await {
match chunk {
Ok(chunk) => bytes.extend(chunk.as_ref()),
Err(e) => {
error!("An error occurred while fetching response data: {}", e);
return Err(FeatureRequesterError::Temporary);
}
}
}
let json = serde_json::from_slice::<AllData<Flag, Segment>>(bytes.as_ref());

return match json {
Expand Down
Loading