Skip to content

Commit 2de8265

Browse files
committed
feat(http): [#191] parse scrape req with multiple infohashes
1 parent 30cf3b9 commit 2de8265

File tree

1 file changed

+11
-10
lines changed
  • src/http/axum_implementation/requests

1 file changed

+11
-10
lines changed

src/http/axum_implementation/requests/scrape.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,20 @@ impl TryFrom<Query> for Scrape {
6060
}
6161

6262
fn extract_info_hashes(query: &Query) -> Result<Vec<InfoHash>, ParseScrapeQueryError> {
63-
match query.get_param(INFO_HASH_SCRAPE_PARAM) {
64-
Some(raw_param) => {
63+
match query.get_param_vec(INFO_HASH_SCRAPE_PARAM) {
64+
Some(raw_params) => {
6565
let mut info_hashes = vec![];
6666

67-
// todo: multiple infohashes
67+
for raw_param in raw_params {
68+
let info_hash =
69+
percent_decode_info_hash(&raw_param).map_err(|err| ParseScrapeQueryError::InvalidInfoHashParam {
70+
param_name: INFO_HASH_SCRAPE_PARAM.to_owned(),
71+
param_value: raw_param.clone(),
72+
source: Located(err).into(),
73+
})?;
6874

69-
let info_hash = percent_decode_info_hash(&raw_param).map_err(|err| ParseScrapeQueryError::InvalidInfoHashParam {
70-
param_name: INFO_HASH_SCRAPE_PARAM.to_owned(),
71-
param_value: raw_param.clone(),
72-
source: Located(err).into(),
73-
})?;
74-
75-
info_hashes.push(info_hash);
75+
info_hashes.push(info_hash);
76+
}
7677

7778
Ok(info_hashes)
7879
}

0 commit comments

Comments
 (0)