如何打印NSMutableURLRequest?

如何使用NSLog打印NSMutableURLRequest?

.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 

你尝试过吗?

 NSLog(@" %@", myMutableURLRequest);