@@ -19,6 +19,14 @@ pub trait Policy<B, E> {
1919 /// The default implementation does nothing.
2020 fn on_request ( & mut self , _request : & mut Request < B > ) { }
2121
22+ /// Invoked right after the service received a response, regardless of whether it is redirected
23+ /// or not.
24+ ///
25+ /// This can for example be used to inspect the response before any redirection is handled.
26+ ///
27+ /// The default implementation does nothing.
28+ fn on_response < Body > ( & mut self , _response : & mut http:: Response < Body > ) { }
29+
2230 /// Loads redirect policy configuration from the request's [`Extensions`].
2331 ///
2432 /// This method is called once at the beginning of request processing to extract
@@ -28,7 +36,9 @@ pub trait Policy<B, E> {
2836 ///
2937 /// The default implementation does nothing, meaning the policy uses its default
3038 /// configuration for all requests.
31- fn on_extensions ( & mut self , _extensions : & Extensions ) ;
39+ ///
40+ /// The default implementation does nothing.
41+ fn on_extensions ( & mut self , _extensions : & Extensions ) { }
3242
3343 /// Returns whether redirection is currently permitted by this policy.
3444 ///
@@ -51,36 +61,6 @@ pub trait Policy<B, E> {
5161 }
5262}
5363
54- impl < B , E , P > Policy < B , E > for & mut P
55- where
56- P : Policy < B , E > + ?Sized ,
57- {
58- #[ inline( always) ]
59- fn redirect ( & mut self , attempt : & Attempt < ' _ > ) -> Result < Action , E > {
60- ( * * self ) . redirect ( attempt)
61- }
62-
63- #[ inline( always) ]
64- fn on_request ( & mut self , request : & mut Request < B > ) {
65- ( * * self ) . on_request ( request)
66- }
67-
68- #[ inline( always) ]
69- fn on_extensions ( & mut self , extensions : & Extensions ) {
70- ( * * self ) . on_extensions ( extensions)
71- }
72-
73- #[ inline( always) ]
74- fn allowed ( & self ) -> bool {
75- ( * * self ) . allowed ( )
76- }
77-
78- #[ inline( always) ]
79- fn clone_body ( & self , body : & B ) -> Option < B > {
80- ( * * self ) . clone_body ( body)
81- }
82- }
83-
8464/// A type that holds information on a redirection attempt.
8565pub struct Attempt < ' a > {
8666 pub ( super ) status : StatusCode ,
0 commit comments