-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bb806b
commit 04b11b6
Showing
5 changed files
with
698 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,294 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Text.Json.Serialization; | ||
using Microsoft365.DeveloperProxy.Abstractions; | ||
|
||
// CDP = Chrome DevTools Protocol | ||
namespace Microsoft365.DeveloperProxy.Plugins.Inspection.CDP; | ||
|
||
public class RequestWillBeSentExtraInfoMessage : Message<RequestWillBeSentExtraInfoParams> | ||
{ | ||
public RequestWillBeSentExtraInfoMessage() | ||
{ | ||
Method = "Network.requestWillBeSentExtraInfo"; | ||
} | ||
} | ||
|
||
public class RequestWillBeSentExtraInfoParams | ||
{ | ||
[JsonPropertyName("requestId")] | ||
public string? RequestId { get; set; } | ||
|
||
[JsonPropertyName("associatedCookies")] | ||
public object[]? AssociatedCookies { get; set; } | ||
|
||
[JsonPropertyName("headers")] | ||
public Dictionary<string, string>? Headers { get; set; } | ||
} | ||
|
||
public class RequestWillBeSentMessage : Message<RequestWillBeSentParams> | ||
{ | ||
public RequestWillBeSentMessage() | ||
{ | ||
Method = "Network.requestWillBeSent"; | ||
} | ||
} | ||
|
||
public class RequestWillBeSentParams | ||
{ | ||
[JsonPropertyName("requestId")] | ||
public string? RequestId { get; set; } | ||
[JsonPropertyName("loaderId")] | ||
public string? LoaderId { get; set; } | ||
[JsonPropertyName("documentURL")] | ||
public string? DocumentUrl { get; set; } | ||
[JsonPropertyName("request")] | ||
public Request? Request { get; set; } | ||
[JsonPropertyName("timestamp")] | ||
public double? Timestamp { get; set; } | ||
[JsonPropertyName("wallTime")] | ||
public long? WallTime { get; set; } | ||
[JsonPropertyName("initiator")] | ||
public Initiator? Initiator { get; set; } | ||
} | ||
|
||
public class ResponseReceivedMessage : Message<ResponseReceivedParams> | ||
{ | ||
public ResponseReceivedMessage() | ||
{ | ||
Method = "Network.responseReceived"; | ||
} | ||
} | ||
|
||
public class ResponseReceivedParams | ||
{ | ||
[JsonPropertyName("requestId")] | ||
public string? RequestId { get; set; } | ||
|
||
[JsonPropertyName("loaderId")] | ||
public string? LoaderId { get; set; } | ||
|
||
[JsonPropertyName("timestamp")] | ||
public double? Timestamp { get; set; } | ||
|
||
[JsonPropertyName("type")] | ||
public string? Type { get; set; } | ||
|
||
[JsonPropertyName("response")] | ||
public Response? Response { get; set; } | ||
|
||
[JsonPropertyName("hasExtraInfo")] | ||
public bool? HasExtraInfo { get; set; } | ||
|
||
[JsonPropertyName("frameId")] | ||
public string? FrameId { get; set; } | ||
} | ||
|
||
public class Response | ||
{ | ||
[JsonPropertyName("url")] | ||
public string? Url { get; set; } | ||
|
||
[JsonPropertyName("status")] | ||
public int? Status { get; set; } | ||
|
||
[JsonPropertyName("statusText")] | ||
public string? StatusText { get; set; } | ||
|
||
[JsonPropertyName("headers")] | ||
public Dictionary<string, string>? Headers { get; set; } | ||
|
||
[JsonPropertyName("mimeType")] | ||
public string? MimeType { get; set; } | ||
|
||
[JsonPropertyName("connectionReused")] | ||
public bool? ConnectionReused { get; set; } | ||
|
||
[JsonPropertyName("connectionId")] | ||
public int? ConnectionId { get; set; } | ||
|
||
[JsonPropertyName("fromDiskCache")] | ||
public bool? FromDiskCache { get; set; } | ||
|
||
[JsonPropertyName("fromServiceWorker")] | ||
public bool? FromServiceWorker { get; set; } | ||
|
||
[JsonPropertyName("fromPrefetchCache")] | ||
public bool? FromPrefetchCache { get; set; } | ||
|
||
[JsonPropertyName("encodedDataLength")] | ||
public int? EncodedDataLength { get; set; } | ||
|
||
[JsonPropertyName("protocol")] | ||
public string? Protocol { get; set; } | ||
|
||
[JsonPropertyName("alternateProtocolUsage")] | ||
public string? AlternateProtocolUsage { get; set; } | ||
|
||
[JsonPropertyName("securityState")] | ||
public string? SecurityState { get; set; } | ||
} | ||
|
||
public class Request | ||
{ | ||
[JsonPropertyName("url")] | ||
public string? Url { get; set; } | ||
[JsonPropertyName("method")] | ||
public string? Method { get; set; } | ||
[JsonPropertyName("headers")] | ||
public Dictionary<string, string>? Headers { get; set; } | ||
[JsonPropertyName("postData")] | ||
public string? PostData { get; set; } | ||
} | ||
|
||
public class Initiator | ||
{ | ||
[JsonPropertyName("type")] | ||
public string? Type { get; set; } | ||
} | ||
|
||
public class LoadingFinishedMessage : Message<LoadingFinishedParams> | ||
{ | ||
public LoadingFinishedMessage() | ||
{ | ||
Method = "Network.loadingFinished"; | ||
} | ||
} | ||
|
||
public class LoadingFinishedParams | ||
{ | ||
[JsonPropertyName("requestId")] | ||
public string? RequestId { get; set; } | ||
|
||
[JsonPropertyName("timestamp")] | ||
public double? Timestamp { get; set; } | ||
|
||
[JsonPropertyName("encodedDataLength")] | ||
public long? EncodedDataLength { get; set; } | ||
} | ||
|
||
public class LoadingFailedMessage : Message<LoadingFailedParams> | ||
{ | ||
public LoadingFailedMessage() | ||
{ | ||
Method = "Network.loadingFailed"; | ||
} | ||
} | ||
|
||
public class LoadingFailedParams | ||
{ | ||
[JsonPropertyName("requestId")] | ||
public string? RequestId { get; set; } | ||
|
||
[JsonPropertyName("timestamp")] | ||
public double? Timestamp { get; set; } | ||
|
||
[JsonPropertyName("type")] | ||
public string? Type { get; set; } | ||
|
||
[JsonPropertyName("errorText")] | ||
public string? ErrorText { get; set; } | ||
|
||
[JsonPropertyName("canceled")] | ||
public bool? Canceled { get; set; } | ||
|
||
[JsonPropertyName("blockedReason")] | ||
public string? BlockedReason { get; set; } | ||
} | ||
|
||
public class EntryAddedMessage : Message<EntryAddedParams> | ||
{ | ||
public EntryAddedMessage() | ||
{ | ||
Method = "Log.entryAdded"; | ||
} | ||
} | ||
|
||
public class EntryAddedParams | ||
{ | ||
[JsonPropertyName("entry")] | ||
public Entry? Entry { get; set; } | ||
} | ||
|
||
public class Entry | ||
{ | ||
[JsonPropertyName("source")] | ||
public string? Source { get; set; } | ||
[JsonPropertyName("level")] | ||
public string? Level { get; set; } | ||
[JsonPropertyName("text")] | ||
public string? Text { get; set; } | ||
[JsonPropertyName("timestamp")] | ||
public double? Timestamp { get; set; } | ||
[JsonPropertyName("url")] | ||
public string? Url { get; set; } | ||
[JsonPropertyName("networkRequestId")] | ||
public string? NetworkRequestId { get; set; } | ||
|
||
public static string GetLevel(MessageType messageType) | ||
{ | ||
return messageType switch | ||
{ | ||
MessageType.Normal => "info", | ||
MessageType.InterceptedRequest => "info", | ||
MessageType.PassedThrough => "info", | ||
MessageType.Warning => "warning", | ||
MessageType.Tip => "info", | ||
MessageType.Failed => "error", | ||
MessageType.Chaos => "error", | ||
MessageType.Mocked => "info", | ||
MessageType.InterceptedResponse => "info", | ||
_ => "info" | ||
}; | ||
} | ||
} | ||
|
||
public class GetResponseBodyMessage : Message<GetResponseBodyParams> | ||
{ | ||
public GetResponseBodyMessage() | ||
{ | ||
Method = "Network.getResponseBody"; | ||
} | ||
} | ||
|
||
public class GetResponseBodyParams | ||
{ | ||
[JsonPropertyName("requestId")] | ||
public string? RequestId { get; set; } | ||
} | ||
|
||
public class GetResponseBodyResult : MessageResult<GetResponseBodyResultParams> | ||
{ | ||
} | ||
|
||
public class GetResponseBodyResultParams | ||
{ | ||
[JsonPropertyName("body")] | ||
public string? Body { get; set; } | ||
[JsonPropertyName("base64Encoded")] | ||
public bool? Base64Encoded { get; set; } | ||
} | ||
|
||
public abstract class MessageResult<TResult> | ||
{ | ||
[JsonPropertyName("id")] | ||
public int Id { get; set; } | ||
[JsonPropertyName("result")] | ||
public TResult? Result { get; set; } | ||
} | ||
|
||
public abstract class Message | ||
{ | ||
[JsonPropertyName("id")] | ||
public int? Id { get; set; } | ||
|
||
[JsonPropertyName("method")] | ||
public string? Method { get; set; } | ||
} | ||
|
||
public abstract class Message<TParams> : Message | ||
{ | ||
[JsonPropertyName("params")] | ||
public TParams? Params { get; set; } | ||
} |
Oops, something went wrong.