How to print AFNetworking request as RAW data

前端 未结 4 815
轮回少年
轮回少年 2020-12-13 01:39

For debuging purposes I\'d want to print whole request body. I\'m using AFHTTPClient. printing client gives some information, like headers but post/get params are not there.

4条回答
  •  没有蜡笔的小新
    2020-12-13 02:07

    As of AFNetworking 2.0, you should use AFNetworkActivityLogger

    #import "AFNetworkActivityLogger.h"
    
    @implementation AppDelegate
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    #ifdef DEBUG
        [[AFNetworkActivityLogger sharedLogger] startLogging];
        [[AFNetworkActivityLogger sharedLogger] setLevel:AFLoggerLevelDebug];
    #endif
        return YES;
    }
    

    If you are using 3.0 and using CocoaPods, you will also need to pull AFNetworkActivityLogger from the appropriate branch:

    pod 'AFNetworkActivityLogger', git: 'https://github.com/AFNetworking/AFNetworkActivityLogger.git', branch: '3_0_0'
    

提交回复
热议问题