HTTP Debugger API v1.0


HTTP Debugger API

HTTP Debugger API allows to view and analyze the HTTP traffic directly from your applications in C++, C# and Java, and control HTTP Debugger from automation scripts, such are PowerShell, JavaScript/NodeJS, etc.

HTTP Debugger API Methods:
  • LoadSettings(path) - loads a configuration file into the API. Configuration files containing HTTP filtering and HTTP modification rules are created and exported from the HTTP Debugger's UI.
  • StartLogger(path) - starts recording HTTP traffic to a given destination folder.
  • StopLogger() - stops recording.

HTTP Debugger API Events:
  • OnRequestHeader( Id, UserName, AppName, IsClient, IpAddr, Url, Header) - is fired after receiving a Request Header.
  • OnRequestContentPacket( Id, PacketData, PacketSize) - is fired after receiving a Request Content
  • OnResponseHeader( Id, Status, Header) - is fired after receiving a Response Header.
  • OnResponseContentPacket( Id, PacketData, PacketSize) - is fired after receiving a Response Content
Where Id is a unique identifier of a particular HTTP session.

API Logs Format

API Log folders have the following format:
Root Path
| - Date
| -- Hour
| --- 0, 1, 2, etc.

where each sub-folder 0,1,2 contains up to 1000 requests.

Each request may contain:
[id]_details.txt - HTTP session details, used for importing logs into the HTTP Debugger UI.
[id]_request_header.txt - request header
[id]_request_content.dat - request content
[id]_response_header.txt - response header
[id]_response_content.dat - response content
where [id] is a number, identifying uniquely a particular session.

You can import any part of those logs into the HTTP Debugger's UI.

API Usage Examples

A sample NodeJS script to log IE traffic:

NodeJS Sample
var win32ole = require('win32ole');

var api = new ActiveXObject("HttpDebugger.Api");
api.LoadSettings("C:\\MySettings\\settings.xml");
api.StartLogger("C:\\Tmp\\Logs");

var ie = new ActiveXObject('InternetExplorer.Application');
ie.Visible = true;
ie.Navigate("http://www.google.com");
win32ole.sleep(5000, true, true);
ie.Quit();
  
api.StopLogger();

The same script on PowerShell:

PowerShell Sample
$api = New-Object -ComObject HttpDebugger.Api
$api.LoadSettings("C:\MySettings\settings.xml");
$res = $api.StartLogger("C:\Tmp\Logs")

$ie = New-Object -ComObject InternetExplorer.Application
$ie.Visible = $true;
$ie.Navigate("http://www.google.com");
[System.Threading.Thread]::Sleep(5000)
$ie.Quit();
  
$api.StopLogger();

A sample C# application outputting URL, Status Code and Content Size (add a reference to "\Program Files (x86)\HTTP Debugger Pro\HTTPDebuggerApi.dll" to your application).

C# Sample      
static void Main(string[] args)
{
    var api = new HttpDebuggerApi();
    api.LoadSettings("C:\\MySettings\\settings.xml");
    api.OnRequestHeader += api_OnRequestHeader;
    api.OnRequestContentPacket += api_OnRequestContentPacket;
    api.OnResponseHeader += api_OnResponseHeader;
    api.OnResponseContentPacket += api_OnResponseContentPacket;

    Console.ReadKey();
}

static void api_OnRequestHeader(uint id, string userName, string appName, bool isClient,string ipAddr,string url, string header)
{
    Console.WriteLine("Request Header: id: {0}, url: {1}", id, url);
}

static void api_OnRequestContentPacket(uint id, ref object packetData, uint packetSize)
{
    var data = packetData as byte[];
    if (data != null)
        Console.WriteLine("Request Content: id: {0}, size: {1}", id, data.Length);           
}

static void api_OnResponseHeader(uint id, string status, string header)
{
    Console.WriteLine("Response Header: id: {0}, status: {1}", id, status);
}

static void api_OnResponseContentPacket(uint id, ref object packetData, uint packetSize)
{
    var data = packetData as byte[];
    if (data != null)
        Console.WriteLine("Response Content: id: {0}, size: {1}", id, data.Length);
}

API Usage Limitations


  • Currently, it is not allowed to run HTTP Debugger's API and UI simultaneously, due to usage of the same networking service.
  • HTTP Debugger API is a 32-bit application; therefore, to run it is required to use 32-bit versions NodeJS, PowerShell, C#, C++ and JAVA applications.