Table of Contents

Save HTTP trafic

fluxzy can store capture trafic to hard drive. This is useful to inspect a trafic later with Fluxzy Desktop or Fluxzy CLI dissect or to share it with other people.

During a capture session, fluxzy can only save the capture traffic to a temporary directory. It's only at the end of the capture session that you can export the traffic to an HAR file or a Fluxzy Archive File (fxzy).

We recommend to use this later as it'is optimized for speed and it supports natively storing the full HTTP level data along with the raw network packets.

To save the traffic, you need to specify the live capture directory by calling the fluent method SetOutDirectory() on the FluxzySetting instance.

var fluxzyStartupSetting = FluxzySetting
    .CreateDefault()
    .SetOutDirectory("my_capture_session_directory");

Then at the end of the capture session, use the Packager helper class to export the directory to a file.

// Export to a fxzy file
Packager.Export("my_capture_session_directory", "my_capture_session.fxzy");

// Export to a HAR file
Packager.ExportAsHttpArchive("my_capture_session_directory", "my_capture_session.har");

With reusing the previous example above, the following full code will save the traffic to a fxzy file.

using System.Net;
using Fluxzy;

var captureDirectory = "my_path"; 

var fluxzyStartupSetting = FluxzySetting
    .CreateDefault(IPAddress.Loopback, 44344)
    .SetOutDirectory(captureDirectory);

using var client = new HttpClient(new HttpClientHandler
{
    Proxy = new WebProxy("localhost", 44344)
});

await using (var proxy = new Proxy(fluxzyStartupSetting))
{
    var endPoints = proxy.Run();

    Console.WriteLine($"Fluxzy is listen on the following endpoints: " +
                      $"{string.Join(" ", endPoints.Select(t => t.ToString()))}");

    await client.GetByteArrayAsync("https://example.com");
}

// Capture to a fxzy file 
Packager.Export(captureDirectory, "my_capture_session.fxzy");

// Capture to a har file
Packager.ExportAsHttpArchive(captureDirectory, "my_capture_session.har");

At the end of the execution, you will find a file named my_capture_session.fxzy in the current directory.

Warning
  • Before calling, Packager.Export() it's recommended to dispose the proxy to ensure that buffered writes are flushed to disk.
  • Fluxzy does not empty the capture directory after a call to Packager.Export(). You need to do it manually if you want to save disk space.