如何打印NSMutableURLRequest?

时间:2011-04-26 06:58:38

标签: iphone objective-c nslog nsmutableurlrequest

如何使用NSLog打印NSMutableURLRequest?

2 个答案:

答案 0 :(得分:82)

.allHTTPHeaderFields返回包含标题内容的字典:

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

或特定领域:

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

答案 1 :(得分:2)

你试过

吗?
NSLog(@" %@", myMutableURLRequest);