@@ -70,14 +70,8 @@ pub fn rustdoc_redirector_handler(req: &mut Request) -> IronResult<Response> {
70
70
}
71
71
let url = ctry ! ( req, Url :: parse( & url_str) ) ;
72
72
let config = extension ! ( req, Config ) ;
73
- let mut resp = Response :: with ( ( status:: Found , Redirect ( url) ) ) ;
74
- resp. headers . set ( CacheControl ( vec ! [
75
- CacheDirective :: MaxAge ( 0 ) ,
76
- // s-maxage is only for the CDN.
77
- CacheDirective :: SMaxAge ( config. cache_rustdoc_redirects) ,
78
- ] ) ) ;
79
-
80
- Ok ( resp)
73
+
74
+ Ok ( super :: cached_redirect ( url, config. cache_rustdoc_redirects ) )
81
75
}
82
76
83
77
fn redirect_to_crate ( req : & Request , name : & str , vers : & str ) -> IronResult < Response > {
@@ -87,14 +81,7 @@ pub fn rustdoc_redirector_handler(req: &mut Request) -> IronResult<Response> {
87
81
) ;
88
82
89
83
let config = extension ! ( req, Config ) ;
90
- let mut resp = Response :: with ( ( status:: Found , Redirect ( url) ) ) ;
91
- resp. headers . set ( CacheControl ( vec ! [
92
- CacheDirective :: MaxAge ( 0 ) ,
93
- // s-maxage is only for the CDN.
94
- CacheDirective :: SMaxAge ( config. cache_rustdoc_redirects) ,
95
- ] ) ) ;
96
-
97
- Ok ( resp)
84
+ Ok ( super :: cached_redirect ( url, config. cache_rustdoc_redirects ) )
98
85
}
99
86
100
87
let metrics = extension ! ( req, Metrics ) . clone ( ) ;
@@ -292,7 +279,7 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
292
279
) ;
293
280
let url = ctry ! ( req, Url :: parse( & redirect_path) ) ;
294
281
295
- Ok ( super :: redirect ( url) )
282
+ Ok ( super :: cached_redirect ( url, config . cache_rustdoc_redirects ) )
296
283
} ;
297
284
298
285
rendering_time. step ( "match version" ) ;
@@ -561,10 +548,7 @@ pub fn target_redirect_handler(req: &mut Request) -> IronResult<Response> {
561
548
) ;
562
549
563
550
let url = ctry ! ( req, Url :: parse( & url) ) ;
564
- let mut resp = Response :: with ( ( status:: Found , Redirect ( url) ) ) ;
565
- resp. headers . set ( Expires ( HttpDate ( time:: now ( ) ) ) ) ;
566
-
567
- Ok ( resp)
551
+ Ok ( super :: cached_redirect ( url, config. cache_rustdoc_redirects ) )
568
552
}
569
553
570
554
pub fn badge_handler ( req : & mut Request ) -> IronResult < Response > {
0 commit comments