Closed artos027 closed 3 months ago
Hi @artos027, may I ask you for a repro code?
After connecting to Page and navigating to url
await pageClient.FireCommandAsync(Page.Enable()); await pageClient.FireCommandAsync(Network.Enable()); await pageClient.FireCommandAsync(Fetch.Enable()); //If I want to check Fetch.PausedRequest
and then a I tried
pageClient.SubscribeAsync
All the information on the request is available, but the headers are empty
I'm launching a browser with a proxy extension, but I tried it without too
Thanks for the repro, I will take a look. Additionally, I suggest you to setup event subscriptions before enabling the related domain, because otherwise you may skip some events which may happen in between these calls.
Thank you so much, I'll be waiting
Seems like it's because of the obscurity of Chrome DevTools Protocol type definitions. The definition for Headers
type is
{
"id": "Headers",
"description": "Request / response headers as keys / values of JSON object.",
"type": "object"
},
So it doesn't have any useful type information to properly map it to a dictionary or something else.
What we can do is generate such types which have no properties (HeadersType
for example) as a subtype of JObject
, which will allow us to preserve JSON context and dynamic properties information, as we are doing in other situations when the exact type is unknown.
The same will be done for "type": "array"
using JArray
in type definitions.
But please be aware that we are planning to migrate from Newtonsoft.Json
to System.Text.Json
in 2.0.0, so it will be a breaking change.
The disadvantage of that approach is that you will need to access properties via indexer, like headers["key"]
but I think it's not a huge problem.
Now it's always an error Newtonsoft.Json.JsonSerializationException and it's impossible to read subscribes
pageClient.SubscribeAsync
Please wait a bit before using the fresh sources, I'm still testing it
Once ready, you will see a new release
When's the new release?)
1-2 days I suppose
@artos027 please try one more time using code from main
:)
new error "System.MissingMethodException" ChromeProtocol.Domains.Network+HeadersType is missing in ObjectTypeConverter.cs in ChromeProtocol.Core
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
{
var jObject = JObject.Load(reader);
var instance = existingValue ?? Activator.CreateInstance(objectType, jObject); // errror in this line
return instance;
}
Are you sure you installed ChromeProtocol.Domains
package in all projects where it may be required at runtime? I'm not aware of your solution structure, so repro is required, since it works in my test suite.
Also, which .NET target framework and runtime do you use? Does your language version cover records?
I'll try again tomorrow and report back with result. .net fr 4.8 windows 11
I was able to reproduce it in .NET Core 3.1 app, will investigate. Seems like some runtime inconsistency because of record types used in Domains assembly.
Yeah, tried it again, same error. The last version didn't have this error.
Please give it a try once you have time. Now it should work on older runtimes too.
Hi, I checked everything(every subscribe with headers), it's all working as it should. Thank you so much!
Thank you for checking! Will release packages soon.
Hi, thanx for library But, can you tell me why the headers are empty in all requests/responses?
PS. I tried Network.Requestwillbesend, Fetch.RequestPaused and so on, everywhere they are empty.