15
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 Firefox Poster plugin, I am successful playing with valid and invalid contents, so its time to move into iOS, unfortunately with iOS it doesn't seem to work correctly tho I always get a response of Bad Request (400) which I suspect is caused by a malformed xml content; So I was thinking before sending the request I want to check if it's on its correct form.
So it boils down to "How can I print out (nslog, etc..) the content of the *request"
Sample code below:
NSURL *URL = [NSURL URLWithString:@"http://xxx.xxx.xxx.xxx/ps"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60];
NSString *msgLength = [NSString stringWithFormat:@"%d", [self.xmlLogin length]];
//NSString *params = [[NSString alloc] initWithFormat:@"%@",[self xmlLogin]];
[request addValue:@"application/xxx.ven.xml" forHTTPHeaderField:@"Content-Type"];
[request addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPMethod:@"POST"];
[request setValue:@"identity" forHTTPHeaderField:@"Accept-Encoding"];
[request setValue:@"windows-1251" forHTTPHeaderField:@"Accept-Charset"];
[request setCachePolicy:NSURLRequestReturnCacheDataElseLoad];
[request setHTTPBody:[[self xmlLogin] dataUsingEncoding:NSUTF8StringEncoding]];
this code snippet
NSLog(@"Request %@\n",request);
results to
<NSMutableURLRequest http://xxx.xxx.xxx.xxx/ps>
while doing something like
NSLog(@"Request %@\n",[request HTTPBody]);
results to
<4c697665 3e383634 30303c2f 54696d65 546f4c69 76653e20 20202020 20202020