Hello all,
When I try to send out a POST request to a specific site the string I try to send gets cut off. When I check the length of the string in Xcode it is about 55000 characters long. The amount of characters received on the site is about 4500. This is my code:
-(IBAction)convert {
NSString *rosterText = [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.innerHTML"];
NSString *params = [[NSString alloc] initWithFormat:@"roster=%@", rosterText];
NSString *paramsLength = [NSString stringWithFormat:@"%d", [params length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://www.thesite/index.php"]];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-type"];
[request setValue:paramsLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]];
NSLog(@"length = %@",paramsLength);
[webView loadRequest:request];
[params release];
[request release];
}
I have a form on the site where you can manually insert the string and that all works fine, so seems to me something is going wrong within the encoding of the POST data.
Anybody know whats going wrong here? Just can't seem to figure it out!
Thanks a lot!