@@ -352,9 +352,7 @@ private bool IsProxiedProcess(TunnelConnectSessionEventArgs e) {
352352 }
353353
354354 async Task OnRequest ( object sender , SessionEventArgs e ) {
355- var method = e . HttpClient . Request . Method . ToUpper ( ) ;
356- // The proxy does not intercept or alter OPTIONS requests
357- if ( method is not "OPTIONS" && IsProxiedHost ( e . HttpClient . Request . RequestUri . Host ) ) {
355+ if ( IsProxiedHost ( e . HttpClient . Request . RequestUri . Host ) ) {
358356 // we need to keep the request body for further processing
359357 // by plugins
360358 e . HttpClient . Request . KeepBody = true ;
@@ -386,20 +384,20 @@ private async Task HandleRequest(SessionEventArgs e) {
386384
387385 // Modify response
388386 async Task OnBeforeResponse ( object sender , SessionEventArgs e ) {
389- var method = e . HttpClient . Request . Method . ToUpper ( ) ;
390387 // read response headers
391- if ( method is not "OPTIONS" && IsProxiedHost ( e . HttpClient . Request . RequestUri . Host ) ) {
388+ if ( IsProxiedHost ( e . HttpClient . Request . RequestUri . Host ) ) {
392389 // necessary to make the response body available to plugins
393390 e . HttpClient . Response . KeepBody = true ;
394- await e . GetResponseBody ( ) ;
391+ if ( e . HttpClient . Response . HasBody ) {
392+ await e . GetResponseBody ( ) ;
393+ }
395394
396395 await _pluginEvents . RaiseProxyBeforeResponse ( new ProxyResponseArgs ( e , _throttledRequests , new ResponseState ( ) ) ) ;
397396 }
398397 }
399398 async Task OnAfterResponse ( object sender , SessionEventArgs e ) {
400- var method = e . HttpClient . Request . Method . ToUpper ( ) ;
401399 // read response headers
402- if ( method is not "OPTIONS" && IsProxiedHost ( e . HttpClient . Request . RequestUri . Host ) ) {
400+ if ( IsProxiedHost ( e . HttpClient . Request . RequestUri . Host ) ) {
403401 _logger . LogRequest ( new [ ] { $ "{ e . HttpClient . Request . Method } { e . HttpClient . Request . Url } " } , MessageType . InterceptedResponse , new LoggingContext ( e ) ) ;
404402 await _pluginEvents . RaiseProxyAfterResponse ( new ProxyResponseArgs ( e , _throttledRequests , new ResponseState ( ) ) ) ;
405403 }
0 commit comments