Skip to content

Commit 3c9e84a

Browse files
committed
spclient: Change RequestOptions to &str
This will allocate less strings and makes it possible to have const request option values. Also document why the metadata base url workaround is needed.
1 parent 24447ff commit 3c9e84a

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

core/src/spclient.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl Default for RequestStrategy {
8888
pub struct RequestOptions {
8989
metrics: bool,
9090
salt: bool,
91-
base_url: Option<String>,
91+
base_url: Option<&'static str>,
9292
}
9393

9494
impl Default for RequestOptions {
@@ -454,7 +454,7 @@ impl SpClient {
454454
// Reconnection logic: retrieve the endpoint every iteration, so we can try
455455
// another access point when we are experiencing network issues (see below).
456456
let mut url = match &options.base_url {
457-
Some(base_url) => base_url.clone(),
457+
Some(base_url) => base_url.to_owned().to_string(),
458458
None => self.base_url().await?,
459459
};
460460
url.push_str(endpoint);
@@ -573,8 +573,11 @@ impl SpClient {
573573

574574
pub async fn get_metadata(&self, scope: &str, id: &SpotifyId) -> SpClientResult {
575575
let endpoint = format!("/metadata/4/{}/{}", scope, id.to_base16()?);
576+
// For unknown reasons, metadata requests must now be sent through spclient.wg.spotify.com.
577+
// Otherwise, the API will respond with 500 Internal Server Error responses.
578+
// Context: https://github.com/librespot-org/librespot/issues/1527
576579
let options = RequestOptions {
577-
base_url: Some(String::from("https://spclient.wg.spotify.com")),
580+
base_url: Some("https://spclient.wg.spotify.com"),
578581
..Default::default()
579582
};
580583
self.request_with_options(&Method::GET, &endpoint, None, None, &options)

0 commit comments

Comments
 (0)