File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ use crate::{
3
3
models:: Version ,
4
4
render:: readme_to_html,
5
5
schema:: { crates, readme_renderings, versions} ,
6
+ uploaders:: Uploader ,
6
7
Config ,
7
8
} ;
8
9
use std:: { io:: Read , path:: Path , sync:: Arc , thread} ;
@@ -15,6 +16,7 @@ use reqwest::{blocking::Client, header};
15
16
use tar:: { self , Archive } ;
16
17
17
18
const CACHE_CONTROL_README : & str = "public,max-age=604800" ;
19
+ const USER_AGENT : & str = "crates-admin" ;
18
20
19
21
#[ derive( Clap , Debug ) ]
20
22
#[ clap(
@@ -160,7 +162,14 @@ fn get_readme(
160
162
. uploader
161
163
. crate_location ( krate_name, & version. num . to_string ( ) ) ;
162
164
163
- let response = match client. get ( & location) . send ( ) {
165
+ let location = match config. uploader {
166
+ Uploader :: S3 { .. } => location,
167
+ Uploader :: Local => format ! ( "http://localhost:8888/{}" , location) ,
168
+ } ;
169
+
170
+ let mut extra_headers = header:: HeaderMap :: new ( ) ;
171
+ extra_headers. insert ( header:: USER_AGENT , USER_AGENT . parse ( ) . unwrap ( ) ) ;
172
+ let response = match client. get ( & location) . headers ( extra_headers) . send ( ) {
164
173
Ok ( r) => r,
165
174
Err ( err) => {
166
175
println ! (
You can’t perform that action at this time.
0 commit comments