JiveLoggingHTTPProtocol
An NSURLProtocol to log HTTP Requests and Responses
Install / Use
/learn @jivesoftware/JiveLoggingHTTPProtocolREADME
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.
Related Skills
node-connect
343.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
92.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.3kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
