Skip to content

Commit

Permalink
Renames Message to MessageLines
Browse files Browse the repository at this point in the history
  • Loading branch information
waldekmastykarz committed Oct 26, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent aee8cfe commit b5c76fe
Showing 6 changed files with 15 additions and 10 deletions.
6 changes: 3 additions & 3 deletions m365-developer-proxy-abstractions/PluginEvents.cs
Original file line number Diff line number Diff line change
@@ -100,13 +100,13 @@ public OptionsLoadedArgs(InvocationContext context) {
}

public class RequestLog {
public string[] Message { get; set; }
public string[] MessageLines { get; set; }
public MessageType MessageType { get; set; }
public LoggingContext? Context { get; set; }

public RequestLog(string[] message, MessageType messageType, LoggingContext? context)
public RequestLog(string[] messageLines, MessageType messageType, LoggingContext? context)
{
Message = message ?? throw new ArgumentNullException(nameof(message));
MessageLines = messageLines ?? throw new ArgumentNullException(nameof(messageLines));
MessageType = messageType;
Context = context;
}
11 changes: 8 additions & 3 deletions m365-developer-proxy-plugins/Inspection/DevToolsPlugin.cs
Original file line number Diff line number Diff line change
@@ -117,14 +117,19 @@ private void SocketMessageReceived(string msg)
if (message?.Method == "Network.getResponseBody")
{
var requestId = message.Params?.RequestId;
if (requestId is null || !responseBody.ContainsKey(requestId))
if (requestId is null ||
!responseBody.ContainsKey(requestId) ||
// should never happen because the message is sent from devtools
// and Id is required on all socket messages but theoretically
// it is possible
message.Id is null)
{
return;
}

var result = new GetResponseBodyResult
{
Id = (int)message.Id!,
Id = (int)message.Id,
Result = new()
{
Body = responseBody[requestId].Body,
@@ -286,7 +291,7 @@ private async void AfterRequestLog(object? sender, RequestLogArgs e)
Entry = new()
{
Source = "network",
Text = string.Join(" ", e.RequestLog.Message),
Text = string.Join(" ", e.RequestLog.MessageLines),
Level = Entry.GetLevel(e.RequestLog.MessageType),
Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
Url = e.RequestLog.Context?.Session.HttpClient.Request.Url,
Original file line number Diff line number Diff line change
@@ -336,7 +336,7 @@ private Dictionary<string, Dictionary<string, Dictionary<string, int>>> GetGroup

private string GetRequestMessage(RequestLog requestLog)
{
return String.Join(' ', requestLog.Message);
return String.Join(' ', requestLog.MessageLines);
}

private string GetMethodAndUrl(RequestLog requestLog)
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ private async void AfterRecordingStop(object? sender, RecordingArgs e)
continue;
}

var methodAndUrlString = request.Message.First();
var methodAndUrlString = request.MessageLines.First();
var methodAndUrl = GetMethodAndUrl(methodAndUrlString);
var requestsFromBatch = Array.Empty<Tuple<string, string>>();

Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ private async void AfterRecordingStop(object? sender, RecordingArgs e)
continue;
}

var methodAndUrlString = request.Message.First();
var methodAndUrlString = request.MessageLines.First();
var methodAndUrl = GetMethodAndUrl(methodAndUrlString);

var uri = new Uri(methodAndUrl.Item2);
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ request.Context is null ||
continue;
}

var methodAndUrlString = request.Message.First();
var methodAndUrlString = request.MessageLines.First();
_logger?.LogDebug($"Processing request {methodAndUrlString}...");

var methodAndUrl = GetMethodAndUrl(methodAndUrlString);

0 comments on commit b5c76fe

Please sign in to comment.