@@ -86,53 +86,13 @@ static ALL_FILTERS: once_cell::sync::Lazy<std::sync::Mutex<adblock::lists::Filte
86
86
// 0th entry is the main default lists
87
87
let default_lists = & default_catalog[ 0 ] . sources ;
88
88
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
-
97
89
assert ! ( default_lists. len( ) > 10 ) ; // sanity check
98
90
99
91
let filters_fut: Vec < _ > = default_lists
100
92
. iter ( )
101
93
. map ( |list| {
102
94
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 )
136
96
. then ( move |resp| {
137
97
let response = resp. expect ( "Could not request rules" ) ;
138
98
if response. status ( ) != 200 {
@@ -142,14 +102,11 @@ static ALL_FILTERS: once_cell::sync::Lazy<std::sync::Mutex<adblock::lists::Filte
142
102
} ) . map ( move |text| {
143
103
let text = text. expect ( "Could not get rules as text" ) ;
144
104
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();
147
105
( list. format , text )
148
106
} )
149
107
} )
150
108
. collect ( ) ;
151
109
152
- // Troubleshooting tip: replace default() below with new(true) to expose raw filters
153
110
let mut filter_set = adblock:: lists:: FilterSet :: default ( ) ;
154
111
155
112
futures:: future:: join_all ( filters_fut)
0 commit comments