Fail opening the stream for anything but HTTP 206

This commit is contained in:
Roderick van Domburg 2022-01-12 22:22:44 +01:00
parent 32df4a401d
commit 8d8d6d4fd8
No known key found for this signature in database
GPG key ID: A9EF5222A26F0451
2 changed files with 7 additions and 2 deletions

View file

@ -428,6 +428,12 @@ impl AudioFileStreaming {
let request_time = Instant::now(); let request_time = Instant::now();
let response = streamer.next().await.ok_or(AudioFileError::NoData)??; 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 let header_value = response
.headers() .headers()
.get(CONTENT_RANGE) .get(CONTENT_RANGE)

View file

@ -61,13 +61,12 @@ async fn receive_data(
}; };
let code = response.status(); let code = response.status();
let body = response.into_body();
if code != StatusCode::PARTIAL_CONTENT { if code != StatusCode::PARTIAL_CONTENT {
debug!("Streamer expected partial content but got: {}", code); debug!("Streamer expected partial content but got: {}", code);
break Err(AudioFileError::StatusCode(code).into()); break Err(AudioFileError::StatusCode(code).into());
} }
let body = response.into_body();
let data = match hyper::body::to_bytes(body).await { let data = match hyper::body::to_bytes(body).await {
Ok(bytes) => bytes, Ok(bytes) => bytes,
Err(e) => break Err(e.into()), Err(e) => break Err(e.into()),