如何使用NSLog打印NSMutableURLRequest?

最佳答案

.allHTTPHeaderFields返回带有标题内容的字典:

NSLog(@"%@", [request allHTTPHeaderFields]);
// {
//    "Accept-Language" = "en;q=1";
//    "Content-Length" = 190706;
//    "Content-Type" = "multipart/form-data; boundary=Boundary+D90A259975186725";
//    "User-Agent" = "...";
// }

或针对特定 Realm :
NSString *field = @"Content-Type";
NSLog(@"%@",[request valueForHTTPHeaderField:field]);
// multipart/form-data; boundary=Boundary+D90A259975186725

关于iphone - 如何打印NSMutableURLRequest?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5787010/

10-11 14:30