View on GitHub

AFHARchiver

An AFNetworking extension to automatically generate HTTP Archive files of all of your network requests!

Download this project as a .zip file Download this project as a tar.gz file

AFHARchiver

An AFNetworking extension to automatically generate a HTTP Archive file of all of your network requests!

Overview

What is HTTP Archiving (HAR)? It's a specification that allows you to store HTTP request/responses as well as meta data, and view that information at a later time to help with debugging.

You can find the HAR specification here, and you can find an online HAR viewer here. You can download a sample HAR log from here and drag it into the online viewer to take a look.

There is also a long list of tools that support the HAR format here.

The full spec has not been fully implemented yet, but basic timing information has been included. By releasing this to the community, we are hopeful more advanced logging data will be implemented.

How to use the HARchiver

Using a HARchiver is as simple as creating an instance of it, and telling it to start. The archiver will archive requests as they come in directly to disk at the path you specify.

self.afArchiver = [[AFHARchiver alloc] initWithPath:path error:nil];
[self.afArchiver startArchiving];

Archiving Specific Requests

You will most likely run into a scenerio where you only want to archive specific requests. The most common use has been to ignore logging image files to prevent your archive from growing too large in size. You can use setShouldArchiveOperationBlock: to provide custom archiving behavior.

[afArchvier setShouldArchiveOperationBlock:^BOOL(AFHTTPRequestOperation *operation) {
    return !([operation isKindOfClass:[AFImageRequestOperation class]]);
}];

A Few TODO's

There is some advanced functionality that has not yet been implemented that will lead to more advanced logs. These include the following:

Contact

Follow Mutual Mobile on Twitter (@MutualMobile)

Creator

Kevin Harwood
@kevinharwood