mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Fail opening the stream for anything but HTTP 206
This commit is contained in:
parent
32df4a401d
commit
8d8d6d4fd8
2 changed files with 7 additions and 2 deletions
|
@ -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)
|
||||||
|
|
|
@ -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()),
|
||||||
|
|
Loading…
Reference in a new issue