ios结构体httpPost头结构

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];


版权声明:本文博客原创文章,博客,未经同意,不得转载。

你可能感兴趣的:(http)