0

I'm building a Flutter app (Web). I want to have a debug section there. Part of it should be dumping HTTP Headers sent to the application. So I'd want to have access to an incoming request. What would be the right way to approach it?

So lets say my app sits at http://my.app. When user hits http://my.app I would like to see contents of their incoming request and then capture parts I'm interesting in like Headers.

Cheers!

Pat
  • 1
  • 1
    _Where_ do you want to see the incoming request? Should the user see it? Do you want it shown in an admin page that you're watching? – Roger Lipscombe Apr 29 '22 at 10:56
  • Honestly, though, most people would just use tcpdump on the server, and then look through the traffic in Wireshark later. On the client, the browser developer tools can show you the HTTP traffic. – Roger Lipscombe Apr 29 '22 at 10:57
  • @RogerLipscombe Thanks for answering. That's an app for Identity Platform operators . I agree it can be done via external tools, sniffers etc. But I'd like to avoid that and present simple information directly on the main page. That app is used to verify whether the integration with Identity Plaftorm works as expected. – Pat Apr 29 '22 at 12:15

1 Answers1

0

There are two different cases. One where you want to get the headers from your HTTP client making requests after your initial page load. This can be done with interceptors where you can access and modify requests when they have been made. Interceptors are implemented by different rest client libraries like dio. Or http_interceptor if you want to work with Flutter's default client.

Accessing the initial request/response parameters is more tricky. I think Keparo's answer is a good reference point here since it should behave the same for JS/Dart in this case.

Nacho
  • 41
  • 4