@@ -88,20 +88,18 @@ export class CompressionHandler implements Middleware {
88
88
span ?. setAttribute ( "http.request.body.size" , compressedBody . size ) ;
89
89
90
90
// execute the next middleware and check if the response code is 415
91
- try {
92
- const response = await this . next ?. execute ( url , requestInit , requestOptions ) ;
93
- if ( response ?. status === 415 ) {
94
- // remove the Content-Encoding header
95
- requestInit . headers . delete ( CompressionHandler . CONTENT_ENCODING_HEADER ) ;
96
- requestInit . body = unCompressedBody . buffer ;
97
- span ?. setAttribute ( "http.request.body.compressed" , false ) ;
98
- span ?. setAttribute ( "http.request.body.size" , unCompressedBodySize ) ;
99
-
100
- return this . next ?. execute ( url , requestInit , requestOptions ) ?? Promise . reject ( new Error ( "Response is undefined" ) ) ;
101
- }
102
- } catch ( error ) {
91
+
92
+ const response = await this . next ?. execute ( url , requestInit , requestOptions ) ;
93
+ if ( response ?. status === 415 ) {
94
+ // remove the Content-Encoding header
95
+ requestInit . headers . delete ( CompressionHandler . CONTENT_ENCODING_HEADER ) ;
96
+ requestInit . body = unCompressedBody . buffer ;
97
+ span ?. setAttribute ( "http.request.body.compressed" , false ) ;
98
+ span ?. setAttribute ( "http.request.body.size" , unCompressedBodySize ) ;
99
+
103
100
return this . next ?. execute ( url , requestInit , requestOptions ) ?? Promise . reject ( new Error ( "Response is undefined" ) ) ;
104
101
}
102
+ return response != null ? Promise . resolve ( response ) : Promise . reject ( new Error ( "Response is undefined" ) ) ;
105
103
}
106
104
107
105
private contentRangeBytesIsPresent ( header : HeadersInit | undefined ) : boolean {
0 commit comments