facebookarchive / stetho

Stetho is a debug bridge for Android applications, enabling the powerful Chrome Developer Tools and much more.
http://facebook.github.io/stetho/
MIT License
12.66k stars 1.13k forks source link

Question: How does Stetho Draw OkHttp Requests in Network Tab? #716

Closed oguzhane closed 1 year ago

oguzhane commented 1 year ago

Firstly, thank you for this inspiring tool that make use of chrome dev tools to ease debugging for developers!

I am very much newbie with chrome dev protocol and trying to understand how stetho reflects intercepted OkHttp requests on chrome dev tool. My understanding from the code here, stetho intercepts http requests/response within the app and supply request/response details as per the protocol spec to the JSONRPC endpoint. Given that the actual request looks to be made within the app, not in the chrome itself.

However, this doesn't seem to be align with the protocol spec because Network.requestWillBeSent is actually an event that gets fired and expected to be handled. The way Stetho making use of it seems to be other way around like, method.

I have played a bit to send fake request to the JSONRPC for the Network.requestWillBeSent but end up getting protocol error.

Appreciate, if you could shed light on how Stetho manages to do that.

Thanks, Oguzhan

oguzhane commented 1 year ago

ok. After looking a bit more into the code base, seems to be Stetho starts a local chrome dev server, those request/response details actually supplied to the local server.