码迷,mamicode.com
首页 > 移动开发 > 详细

ios构造httpPost头结构

时间:2014-08-25 22:59:35      阅读:415      评论:0      收藏:0      [点我收藏+]

标签:ios

ios构造httpPost头结构

by 伍雪颖

NSString* urlStr = @";
NSURL* url = [NSURL URLWithString:urlStr];
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url];
request.HTTPMethod = @"POST";
[request addValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
NSString *postStr = @"";
[request setHTTPBody:[postStr dataUsingEncoding:NSUTF8StringEncoding]];

NSURLSessionConfiguration* config = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession* session = [NSURLSession sessionWithConfiguration:config];

NSURLSessionDataTask* dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
    if (error == nil) {
    }
}];
[dataTask resume];


ios构造httpPost头结构

标签:ios

原文地址:http://blog.csdn.net/rainlesvio/article/details/38826903

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!