Skip to content

Commit

Permalink
player/fetch.rs: fix bug of crash on some song
Browse files Browse the repository at this point in the history
Crash is caused by the file passed to mp3_duration is a error response
instread of mp3 file because the HOST field in request header does not
match the url.
  • Loading branch information
sunriseL committed Nov 25, 2021
1 parent 75bf455 commit ccf65a9
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/player/fetch.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::io::prelude::*;
use futures::channel::oneshot::Sender;
use reqwest::header::{HOST, CACHE_CONTROL, PRAGMA, HeaderMap, UPGRADE_INSECURE_REQUESTS, ACCEPT, ACCEPT_ENCODING, USER_AGENT};
use reqwest::header::{CACHE_CONTROL, PRAGMA, HeaderMap, UPGRADE_INSECURE_REQUESTS, ACCEPT, ACCEPT_ENCODING, USER_AGENT};
use reqwest::Method;
use tempfile::NamedTempFile;

Expand All @@ -14,7 +14,6 @@ pub async fn fetch_data(url: &str, buffer: NamedTempFile, tx: Sender<String>) ->
headers.insert(CACHE_CONTROL, "no-cache".parse().unwrap());
headers.insert(PRAGMA, "no-cache".parse().unwrap());
headers.insert(UPGRADE_INSECURE_REQUESTS, "1".parse().unwrap());
headers.insert(HOST, "m7.music.126.net".parse().unwrap());
headers.insert(ACCEPT, "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3".parse().unwrap());
headers.insert(ACCEPT_ENCODING, "gzip,deflate".parse().unwrap());
headers.insert(
Expand Down

0 comments on commit ccf65a9

Please sign in to comment.