Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excludes processing OPTIONS responses. Closes #371 #374

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions m365-developer-proxy/ProxyEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}

public async Task Run(CancellationToken? cancellationToken) {

Check warning on line 63 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 63 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.
if (!_urlsToWatch.Any()) {
_logger.LogInfo("No URLs to watch configured. Please add URLs to watch in the m365proxyrc.json config file.");
return;
Expand All @@ -73,7 +73,7 @@
var _logger2 = (ILogger)_logger.Clone();
_logger2.LogLevel = LogLevel.Warn;
// let's not await so that it doesn't block the proxy startup
MSGraphDbCommandHandler.GenerateMsGraphDb(_logger2, true);

Check warning on line 76 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 76 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.

_proxyServer = new ProxyServer();

Expand Down Expand Up @@ -148,7 +148,7 @@
StartRecording();
}
if (key == ConsoleKey.S) {
StopRecording();

Check warning on line 151 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 151 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.
}
if (key == ConsoleKey.C) {
Console.Clear();
Expand Down Expand Up @@ -384,8 +384,9 @@

// 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 @@ -393,11 +394,12 @@
await _pluginEvents.RaiseProxyBeforeResponse(new ProxyResponseArgs(e, _throttledRequests, new ResponseState()));
}
}
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
Loading