Skip to content

Commit

Permalink
Move first check outside of loop and refactor into while
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Jan 22, 2024
1 parent a0975fc commit 25dd1a8
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions neqo-client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,11 @@ fn main() -> Res<()> {
});

for ((host, port), mut urls) in urls_by_origin {
if args.resume && urls.len() < 2 {
eprintln!("Resumption to {host} cannot work without at least 2 URLs.");
exit(127);
}

let remote_addr = format!("{host}:{port}").to_socket_addrs()?.find(|addr| {
!matches!(
(addr, args.ipv4_only, args.ipv6_only),
Expand Down Expand Up @@ -1082,24 +1087,13 @@ fn main() -> Res<()> {

let hostname = format!("{host}");
let mut token: Option<ResumptionToken> = None;
let mut first = true;
loop {
let to_request = if (args.resume && first) || args.download_in_series {
if args.resume && first && urls.len() < 2 {
println!(
"Error: resumption to {hostname} cannot work without at least 2 URLs."
);
exit(127);
}
while !urls.is_empty() {
let to_request = if args.resume || args.download_in_series {
urls.pop_front().into_iter().collect()
} else {
std::mem::take(&mut urls)
};
if to_request.is_empty() {
break;
}

first = false;
token = if args.use_old_http {
old::old_client(
&args,
Expand Down

0 comments on commit 25dd1a8

Please sign in to comment.