How to print NSMutableURLRequest?
Asked Answered
T

2

41

How to print NSMutableURLRequest using NSLog ?

Triangular answered 26/4, 2011 at 6:58 Comment(0)
R
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
Rochellrochella answered 26/4, 2011 at 7:11 Comment(0)
P
2

Did you try with

NSLog(@" %@", myMutableURLRequest);
Profluent answered 26/4, 2011 at 7:1 Comment(3)
request = <NSMutableURLRequest 112.152.8.204/Service1.asmx> This is wat am getting in logs. But I need to see the values added to it including header settings :(Triangular
@chaitanya: If you want to make sure you get the headers out, you need to edit your question to say so. As it stands, this is the correct answer (hence +1 from me).Manicure
#chaitanya : i meant your NSMutableURLRequest values :)Profluent

© 2022 - 2024 — McMap. All rights reserved.