• Stars
    star
    102
  • Rank 335,584 (Top 7 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 12 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"log.har"];

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

Archiving Specific AFHTTPRequestOperations / NSURLSessionTasks

You will most likely run into a scenario where you only want to archive specific operations. The most common use has been to ignore logging image files to prevent your archive from growing too large in size. For AFHTTPRequestOperations, you can use setShouldArchiveOperationBlock:. For NSURLSessionTasks, you can use setShouldArchiveTaskBlock:.

[self.afArchiver
 setShouldArchiveOperationBlock:^BOOL(AFHTTPRequestOperation *operation) {
     return [operation.responseSerializer isKindOfClass:[AFJSONResponseSerializer class]];
 }];
 
[self.afArchiver
 setShouldArchiveTaskBlock:^BOOL(NSURLSessionTask *task, id<AFURLResponseSerialization> responseSerializer, id serializedResponse) {
     return [(NSObject*)responseSerializer isKindOfClass:[AFJSONResponseSerializer class]];
 }];
}];

##Using AFNetworking 2.0.0, iOS 6, and NSURLConnection

If your application is using AFNetworking 2.0.0, targeting iOS 6, and using the NSURLConnection API's, continue to use AFHARchiver 0.1.0. The current version of AFHARchiver requires the AF/NSURLSession API's included in AFNetworking 2.0.0.

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.
  • Calculate the correct headerSize.

Credits

Created by Kevin Harwood (Email | Twitter) at Mutual Mobile.

License

AFHARchiver is available under the MIT license. See the LICENSE file for more info

More Repositories

1

MMDrawerController

A lightweight, easy to use, Side Drawer Navigation Controller
Objective-C
6,760
star
2

MMWormhole

Message passing between iOS apps and extensions.
Objective-C
3,926
star
3

MMProgressHUD

An easy-to-use HUD interface with personality.
Objective-C
705
star
4

MMRecord

Seamless Web Service Integration and Core Data Model Population
Objective-C
691
star
5

VIPER-SWIFT

An example Todo list app written in Swift using the VIPER architecture.
Swift
502
star
6

CardStackUI

An iOS Healthbook-like highly customisable stack of cards implementation for Android
Kotlin
465
star
7

Praxis

Example Android project using MVVM, DaggerAndroid, Jetpack Compose, Retrofit, Coroutines and Multi module architecture ✌🏽
Kotlin
353
star
8

Counter

A simple example of the VIPER architecture for iOS apps
Objective-C
351
star
9

MMBarricade

Runtime configurable local server for iOS apps.
Objective-C
350
star
10

ComposeSensors

Access sensor data for any Android device easily using Jetpack Compose 🌡️ 🧲 🧭
Kotlin
207
star
11

compose-animation-examples

Compose Animation Examples. Useful Jetpack Compose animations including Loading/progress, Looping, On-off, Enter, Exit, Fade, Spin and Background animations that you can take inspiration from.
Kotlin
203
star
12

MMSpreadsheetView

Objective-C
193
star
13

lavaca

A modern framework for client-side MVC web applications
JavaScript
105
star
14

gradle-dexinfo-plugin

Java
71
star
15

VIPER-TODO

Example project architected using VIPER
Objective-C
70
star
16

PraxisKMP

A Kotlin multiplatform base project
Kotlin
49
star
17

HarvestTimeKMP

A Kotlin multiplatform playground project for getharvest time logger clone.
Kotlin
44
star
18

Barricade

⛔️ DEPRECATED (Click on the link below to check out Barricade2) - Runtime configurable local server for Android apps.
Java
42
star
19

SeatLayout

A seat selection library for Android with an example for selecting seats for flights, sports venue, theatres, etc
Java
39
star
20

lavaca-starter

A starter app for lavaca
CSS
34
star
21

PraxisFlutter

Example Flutter Project using Clean Architecture
Dart
29
star
22

FitWatchCompose

Kotlin
21
star
23

MMKeystore

A Keystore library for Android apps that allows you to encrypt sensitive information, The encryption uses the Android KeyStore to generate RSA and AES keys for encryption operations.
Kotlin
13
star
24

UberBookingClone

Kotlin
13
star
25

cordova-bluetoothle

Cordova Bluetooth Low Energy plugin for iOS and Android
Objective-C
12
star
26

Barricade2

Runtime configurable local server for Android apps.
Kotlin
9
star
27

flutter_animations_example

Flutter Animation Examples. Useful Flutter animations including Loading/progress, Looping, On-off, Enter, Exit, Fade, Spin and Background animations that you can take inspiration from.
Dart
8
star
28

react-native-barricade

A local server configurable at runtime to develop, test, and prototype your React Native app.
TypeScript
8
star
29

HolidayCard

Build a Holiday Card for Hour of Code in Swift!
Swift
8
star
30

Brazos

A React web React Native starter with tooling for large scale projects
JavaScript
7
star
31

MM-Dribbble

A fun app to use at Dribbble meetups across the world!
4
star
32

clover-reporting

A reporting tool using the Clover REST API
HTML
3
star
33

dust_compiler

A simple Node command line tool that watches and compiles dust templates recursively from one directory to another
JavaScript
3
star
34

XcodeSortInstaller

A simple gem to install a new build phase on your Xcode project file to (on modification) sort itself on build.
Ruby
2
star
35

Google-Analytics

Storing Google Analytics Source Code for Cocoa Pods
Objective-C
2
star
36

SwiftUIAnimations

Playground for swiftui animations
Swift
2
star
37

Library

Library App that holds a shelf of books, and a detail view of each book that shows information about it like the book's Author, Publisher, Book ID/ISBN number and so on.
Objective-C
2
star
38

HarvestAPISpring

Kotlin
1
star
39

ReactFirebaseAuthComponent

Reusable code for simple authentication and integration with Firebase
JavaScript
1
star
40

ZomatoClone

Kotlin
1
star
41

clover.mutualmobile.com

CSS
1
star
42

seven68

Seven68 is a Objective-C library for iPad developers.
1
star