@@ -111,24 +111,25 @@ async fn convert_body(app_response: reqwest::Response) -> Result<Body, Error> {
111111 return Ok ( Body :: Binary ( content. to_vec ( ) ) ) ;
112112 }
113113
114- let content_type = if let Some ( value) = app_response. headers ( ) . get ( http:: header:: CONTENT_TYPE ) {
115- value. to_str ( ) . unwrap_or_default ( )
116- } else {
117- ""
118- } ;
114+ match app_response. headers ( ) . get ( http:: header:: CONTENT_TYPE ) {
115+ Some ( value) => {
116+ let content_type = value. to_str ( ) . unwrap_or_default ( ) ;
119117
120- if content_type. starts_with ( "text" )
121- || content_type. starts_with ( "application/json" )
122- || content_type. starts_with ( "application/javascript" )
123- || content_type. starts_with ( "application/xml" )
124- {
125- let body_text = app_response. text ( ) . await ?;
126- return Ok ( Body :: Text ( body_text) ) ;
127- }
128- let content = app_response. bytes ( ) . await ?;
129- if !content. is_empty ( ) {
130- Ok ( Body :: Binary ( content. to_vec ( ) ) )
131- } else {
132- Ok ( Body :: Empty )
118+ if content_type. starts_with ( "text" )
119+ || content_type. starts_with ( "application/json" )
120+ || content_type. starts_with ( "application/javascript" )
121+ || content_type. starts_with ( "application/xml" )
122+ {
123+ Ok ( Body :: Text ( app_response. text ( ) . await ?) )
124+ } else {
125+ let content = app_response. bytes ( ) . await ?;
126+ if content. is_empty ( ) {
127+ Ok ( Body :: Empty )
128+ } else {
129+ Ok ( Body :: Binary ( content. to_vec ( ) ) )
130+ }
131+ }
132+ }
133+ None => Ok ( Body :: Text ( app_response. text ( ) . await ?) ) ,
133134 }
134135}
0 commit comments