I want to ask if anybody has ever tried printing out the values of a NSMutableURLRequest *request;
Here\'s my scenario, I have formed my XML and tried sending it using F
NSLog(@"Request body %@", [[NSString alloc] initWithData:[request HTTPBody] encoding:NSUTF8StringEncoding]);
- (NSString *)formatURLRequest:(NSURLRequest *)request
{
NSMutableString *message = [NSMutableString stringWithString:@"---REQUEST------------------\n"];
[message appendFormat:@"URL: %@\n",[request.URL description] ];
[message appendFormat:@"METHOD: %@\n",[request HTTPMethod]];
for (NSString *header in [request allHTTPHeaderFields])
{
[message appendFormat:@"%@: %@\n",header,[request valueForHTTPHeaderField:header]];
}
[message appendFormat:@"BODY: %@\n",[[NSString alloc] initWithData:[request HTTPBody] encoding:NSUTF8StringEncoding]];
[message appendString:@"----------------------------\n"];
return [NSString stringWithFormat:@"%@",message];
}
- (NSString *)formatURLResponse:(NSHTTPURLResponse *)response withData:(NSData *)data
{
NSString *responsestr = [[NSString alloc] initWithBytes:[data bytes] length:[data length] encoding:NSUTF8StringEncoding];
NSMutableString *message = [NSMutableString stringWithString:@"---RESPONSE------------------\n"];
[message appendFormat:@"URL: %@\n",[response.URL description] ];
[message appendFormat:@"MIMEType: %@\n",response.MIMEType];
[message appendFormat:@"Status Code: %ld\n",(long)response.statusCode];
for (NSString *header in [[response allHeaderFields] allKeys])
{
[message appendFormat:@"%@: %@\n",header,[response allHeaderFields][header]];
}
[message appendFormat:@"Response Data: %@\n",responsestr];
[message appendString:@"----------------------------\n"];
return [NSString stringWithFormat:@"%@",message];
}