//设置HTTP Content-Length
NSString *lenStr = [NSString stringWithFormat:@"%ld",request.HTTPBody.length];
[request setValue:lenStr forHTTPHeaderField:@"Content-Length"];
//设置HTTP Content-Type
[request setValue:formData.contentType forHTTPHeaderField:@"Content-Type"];
// 5.发送请求
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
//处理请求结果
}];
转载于:https://blog.51cto.com/451143112/1651780