Skip to content

Commit 00c6ff1

Browse files
committed
remove outdated easylist host redirection
1 parent b3ad9b8 commit 00c6ff1

File tree

1 file changed

+1
-44
lines changed

1 file changed

+1
-44
lines changed

tests/live.rs

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -86,53 +86,13 @@ static ALL_FILTERS: once_cell::sync::Lazy<std::sync::Mutex<adblock::lists::Filte
8686
// 0th entry is the main default lists
8787
let default_lists = &default_catalog[0].sources;
8888

89-
println!(
90-
"List of filter lists has {} filter lists total",
91-
default_lists.len()
92-
);
93-
// ↑ Question about that:
94-
// How many filter lists could a list of filter lists list if a list of filter lists could list filter lists?
95-
// (asking for a friend, who may or may not be a woodchuck)
96-
9789
assert!(default_lists.len() > 10); // sanity check
9890

9991
let filters_fut: Vec<_> = default_lists
10092
.iter()
10193
.map(|list| {
10294
println!("Starting download of filter, '{}'", list.url);
103-
// 'easylist.to' is deployed via GitHub Pages. However, sometimes 'easylist.to' can
104-
// take minutes to respond despite 'easylist.github.io' having no delay.
105-
//
106-
// In one test, the first request below ↓ took <1 second, and the second request took ~7 minutes
107-
// time curl --fail -H 'Host: easylist.to' https://easylist.github.io/easylist/easylist.txt -o /dev/null
108-
// time curl --fail https://easylist.to/easylist/easylist.txt -o /dev/null
109-
//
110-
// Toggle the `cfg` below if encountering this issue during local development.
111-
// (e.g., add '--cfg override_easylist_host' to RUSTFLAGS)
112-
#[cfg(any(override_easylist_host))]
113-
let downloader = {
114-
let client = reqwest::Client::builder()
115-
.redirect(reqwest::redirect::Policy::none())
116-
.build()
117-
.unwrap();
118-
if list.url.starts_with("https://easylist.to") {
119-
// The use of 'http' rather than 'https' below is intentional. reqwest only
120-
// respects the host header if the target url is http, not https. (Unclear
121-
// whether that's a bug or intentional behavior.) One way to confirm that is
122-
// to send requests to http://httpbin.org/headers instead of github.io.
123-
client
124-
.get(&list.url.replace("https://easylist.to", "http://easylist.github.io"))
125-
.header(reqwest::header::HOST, "easylist.to")
126-
.send()
127-
} else {
128-
// leave all other filter list requests unmodified
129-
client.get(&list.url).send()
130-
}
131-
};
132-
133-
#[cfg(not(override_easylist_host))]
134-
let downloader = reqwest::get(&list.url);
135-
downloader
95+
reqwest::get(&list.url)
13696
.then(move |resp| {
13797
let response = resp.expect("Could not request rules");
13898
if response.status() != 200 {
@@ -142,14 +102,11 @@ static ALL_FILTERS: once_cell::sync::Lazy<std::sync::Mutex<adblock::lists::Filte
142102
}).map(move |text| {
143103
let text = text.expect("Could not get rules as text");
144104
println!("Finished download of filter, '{}' ({} bytes)", list.url, text.len());
145-
// Troubleshooting tip: uncomment the next line to save the downloaded filter lists
146-
// std::fs::write(format!("target/{}.txt", list.title), &text).unwrap();
147105
( list.format, text )
148106
})
149107
})
150108
.collect();
151109

152-
// Troubleshooting tip: replace default() below with new(true) to expose raw filters
153110
let mut filter_set = adblock::lists::FilterSet::default();
154111

155112
futures::future::join_all(filters_fut)

0 commit comments

Comments
 (0)