Skip to content

fanweixiao/AFHARchiver

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

  • Split the duration of the request into the proper time buckets. Currently all time is passed to the duration bucket.
  • Determine if responses are returning from a local cache using the cache property.
  • Log all cookie information to the cookie property.
  • Include redirect information in the redirectURL property.
  • Calculate the correct headerSize.

Contact

Follow Mutual Mobile on Twitter (@MutualMobile)

Creator

Kevin Harwood
@kevinharwood

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published