Git Product home page Git Product logo

jivelogginghttpprotocol's Introduction

JiveLoggingHTTPProtocol

Based on Apple's CustomHTTPProtocol, JLHPLoggingHTTPProtocol logs to the console all requests and responses visibile to the NSURLProtocol system. This should only be used for debugging. It won't show all HTTP interactions because authentication interactions aren't visible to the NSURLProtocol system. For example, NTLM uses multiple HTTP requests and responses for authentication before the request that the NSURLProtocol system sees is accepted. Additionally, some iOS frameworks' HTTP calls aren't visible to the NSURLProtocol system at all (AV Foundation streaming).

Usage

Call +[JLHPLoggingHTTPProtocol start] as early as possible in your Application's lifecycle because NSURLProtocol registrations are called in reverse-registration-order (the first NSURLProtocol registered is the last one called). If other NSURLProtocols modify a request, those modifications should happen before JLHPLoggingHTTPProtocol is called.

A good safe place to call +[JLHPLoggingHTTPProtocol start] early is in main.m. Since this should only be used for debugging +[JLHPLoggingHTTPProtocol start] should be guarded somehow to ensure it is only called in debug mode. In the example below, the Xcode scheme inserts arguments that will populate NSUserDefaults to trigger the call.

//
//  main.m
//  JiveLoggingHTTPProtocolDemo
//
//  Created by Heath Borders on 3/2/15.
//  Copyright (c) 2015 Jive Software. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#import <JiveLoggingHTTPProtocol/JLHPLoggingHTTPProtocol.h>

int main(int argc, char * argv[]) {
    @autoreleasepool {
        // NSUserDefaults grab any program arguments with the format `-name value`.
        // In the JiveLoggingHTTPProtocolDemo scheme, we have `-logHTTP YES` defined.
        if ([[NSUserDefaults standardUserDefaults] boolForKey:@"logHTTP"]) {
            [JLHPLoggingHTTPProtocol start];
        }
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}

License

BSD per the LICENSE file.

jivelogginghttpprotocol's People

Contributors

hborders avatar neonichu avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.