diff --git a/audio/src/fetch/mod.rs b/audio/src/fetch/mod.rs index 1e0070d7..ef19a45a 100644 --- a/audio/src/fetch/mod.rs +++ b/audio/src/fetch/mod.rs @@ -428,6 +428,12 @@ impl AudioFileStreaming { let request_time = Instant::now(); let response = streamer.next().await.ok_or(AudioFileError::NoData)??; + let code = response.status(); + if code != StatusCode::PARTIAL_CONTENT { + debug!("Streamer expected partial content but got: {}", code); + return Err(AudioFileError::StatusCode(code).into()); + } + let header_value = response .headers() .get(CONTENT_RANGE) diff --git a/audio/src/fetch/receive.rs b/audio/src/fetch/receive.rs index 274f0c89..568efafd 100644 --- a/audio/src/fetch/receive.rs +++ b/audio/src/fetch/receive.rs @@ -61,13 +61,12 @@ async fn receive_data( }; let code = response.status(); - let body = response.into_body(); - if code != StatusCode::PARTIAL_CONTENT { debug!("Streamer expected partial content but got: {}", code); break Err(AudioFileError::StatusCode(code).into()); } + let body = response.into_body(); let data = match hyper::body::to_bytes(body).await { Ok(bytes) => bytes, Err(e) => break Err(e.into()),