How to print NSMutableURLRequest?

Krishna Chaitanya Bandaru picture Krishna Chaitanya Bandaru · Apr 26, 2011 · Viewed 23k times · Source

How to print NSMutableURLRequest using NSLog ?

Answer

visakh7 picture visakh7 · Apr 26, 2011

.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