Skip to content

Commit

Permalink
Excludes processing OPTIONS responses. Closes #371
Browse files Browse the repository at this point in the history
  • Loading branch information
waldekmastykarz committed Oct 31, 2023
1 parent 79e87e8 commit de0b5aa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions m365-developer-proxy/ProxyEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,9 @@ private async Task HandleRequest(SessionEventArgs e) {

// Modify response
async Task OnBeforeResponse(object sender, SessionEventArgs e) {
var method = e.HttpClient.Request.Method.ToUpper();
// read response headers
if (IsProxiedHost(e.HttpClient.Request.RequestUri.Host)) {
if (method is not "OPTIONS" && IsProxiedHost(e.HttpClient.Request.RequestUri.Host)) {
// necessary to make the response body available to plugins
e.HttpClient.Response.KeepBody = true;
await e.GetResponseBody();
Expand All @@ -394,8 +395,9 @@ async Task OnBeforeResponse(object sender, SessionEventArgs e) {
}
}
async Task OnAfterResponse(object sender, SessionEventArgs e) {

Check warning on line 397 in m365-developer-proxy/ProxyEngine.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 397 in m365-developer-proxy/ProxyEngine.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
var method = e.HttpClient.Request.Method.ToUpper();
// read response headers
if (IsProxiedHost(e.HttpClient.Request.RequestUri.Host)) {
if (method is not "OPTIONS" && IsProxiedHost(e.HttpClient.Request.RequestUri.Host)) {
_logger.LogRequest(new[] { $"{e.HttpClient.Request.Method} {e.HttpClient.Request.Url}" }, MessageType.InterceptedResponse, new LoggingContext(e));
_pluginEvents.RaiseProxyAfterResponse(new ProxyResponseArgs(e, _throttledRequests, new ResponseState()));

Check warning on line 402 in m365-developer-proxy/ProxyEngine.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check warning on line 402 in m365-developer-proxy/ProxyEngine.cs

View workflow job for this annotation

GitHub Actions / build

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
}
Expand Down

0 comments on commit de0b5aa

Please sign in to comment.