Search code examples
iphoneobjective-cnslognsmutableurlrequest

How to print NSMutableURLRequest?


How to print NSMutableURLRequest using NSLog ?


Solution

  • .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