41

How to print NSMutableURLRequest using NSLog ?

Oak Bytes
  • 4,649
  • 4
  • 36
  • 53

2 Answers2

90

.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
tobiasdm
  • 9,688
  • 1
  • 18
  • 15
visakh7
  • 26,380
  • 8
  • 55
  • 69
2

Did you try with

NSLog(@" %@", myMutableURLRequest);
Jhaliya - Praveen Sharma
  • 31,697
  • 9
  • 72
  • 76