object-c Http请求-2

http get

----------------------------

NSString *url = @"http://wwww.baidu.com";

    NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];

    

    [urlRequest setHTTPMethod:@"GET"];

    NSData *returnData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:nil error:nil];         

    

    NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];   

    

    NSLog(@"%@",returnString); 

----------------------------

 

POST 表单提交

[urlRequest setValue: [NSString stringWithFormat:@"multipart/form-data; boundary=%@", BOUNDRY]         forHTTPHeaderField:@"Content-Type"];

你可能感兴趣的:(object)