Skip to content

Commit

Permalink
feat(http): [#191] parse scrape req with multiple infohashes
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed Feb 23, 2023
1 parent 30cf3b9 commit 2de8265
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/http/axum_implementation/requests/scrape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,20 @@ impl TryFrom<Query> for Scrape {
}

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

// todo: multiple infohashes
for raw_param in raw_params {
let info_hash =
percent_decode_info_hash(&raw_param).map_err(|err| ParseScrapeQueryError::InvalidInfoHashParam {
param_name: INFO_HASH_SCRAPE_PARAM.to_owned(),
param_value: raw_param.clone(),
source: Located(err).into(),
})?;

let info_hash = percent_decode_info_hash(&raw_param).map_err(|err| ParseScrapeQueryError::InvalidInfoHashParam {
param_name: INFO_HASH_SCRAPE_PARAM.to_owned(),
param_value: raw_param.clone(),
source: Located(err).into(),
})?;

info_hashes.push(info_hash);
info_hashes.push(info_hash);
}

Ok(info_hashes)
}
Expand Down

0 comments on commit 2de8265

Please sign in to comment.