How to print NSMutableURLRequest?

我们两清 提交于 2019-12-18 11:06:37

问题


How to print NSMutableURLRequest using NSLog ?


回答1:


.allHTTPHeaderFields returns a dictionary with the header content:

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

Or for specific field:

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



回答2:


Did you try with

NSLog(@" %@", myMutableURLRequest);


来源:https://stackoverflow.com/questions/5787010/how-to-print-nsmutableurlrequest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!