如何使用NSLog打印NSMutableURLRequest?
答案 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);