File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,9 @@ impl Downloader {
2121 pub ( crate ) fn new ( ) -> Result < Self , Error > {
2222 Ok ( Self {
2323 storage : TempDir :: new ( ) ?,
24- http : Client :: new ( ) ,
24+ http : Client :: builder ( )
25+ . user_agent ( "https://github.com/rust-lang/ci-mirrors" )
26+ . build ( ) ?,
2527 } )
2628 }
2729
@@ -32,15 +34,16 @@ impl Downloader {
3234 } ;
3335 eprintln ! ( "downloading {url}..." ) ;
3436
35- let mut reader = StreamReader :: new (
36- self . http
37- . get ( url. clone ( ) )
38- . send ( )
39- . await ?
40- . error_for_status ( ) ?
41- . bytes_stream ( )
42- . map_err ( std:: io:: Error :: other) ,
43- ) ;
37+ let resp = self . http . get ( url. clone ( ) ) . send ( ) . await ?;
38+ if !resp. status ( ) . is_success ( ) {
39+ bail ! (
40+ "failed to download with status {}: {url}\n === body ===\n {}\n ============\n " ,
41+ resp. status( ) ,
42+ resp. text( ) . await ?
43+ ) ;
44+ }
45+
46+ let mut reader = StreamReader :: new ( resp. bytes_stream ( ) . map_err ( std:: io:: Error :: other) ) ;
4447
4548 let dest = File :: create ( self . path_for ( file) ) . await ?;
4649 let mut writer = Sha256Writer :: new ( BufWriter :: new ( dest) ) ;
You can’t perform that action at this time.
0 commit comments