nsmutableurlrequest

How to check the NSDATA type?

泪湿孤枕 提交于 2019-12-11 04:46:48
问题 I have the class which downloads images First I have NSMutable URLRequest than I establish NSURLConnection and than I want to check which data I received in this function - (void)connectionDidFinishLoading:(NSURLConnection *)connection If it is image than write to the folder when it is some text than skip to the next image. How do I check the type of received data? 回答1: In delegate method of NSURLConnection, you can get header of response, from which you can get content type. If content type

NSURLErrorDomain Code=-1012 The operation couldn’t be completed

ぐ巨炮叔叔 提交于 2019-12-10 14:37:57
问题 I am getting the following error when running my code from the xcode. Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)" UserInfo=0x17166b740 {NSErrorFailingURLStringKey= https://..../move/resource/v1/user/me/activity/summary?start_date=2015-01-21&end_date=2015-01-14&detail=true , NSUnderlyingError=0x17405b630 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1012.)", NSErrorFailingURLKey= https://..../move

Request to web service over SSL

此生再无相见时 提交于 2019-12-09 10:23:59
问题 i am struggling to request web service using https. I am getting this kind of error: An error occured : The certificate for this server is invalid. You might be connecting to a server that is pretending to be “SERVER_ADDRESS” which could put your confidential information at risk. I am not using NSUrlConnectionDelegate. Here is my method: - (void)sendRequestWithUrl:(NSURL*)url block:(void (^)(NSDictionary *dict, NSError *error)) block{ NSMutableURLRequest *request = [NSMutableURLRequest

How can I send an email with attachement using the API MailJet in iOS programmatically?

别等时光非礼了梦想. 提交于 2019-12-08 07:27:08
问题 FIRST ERROR I use this code but I don't know how to use the api Mailjet in iOS ? Where to put the API key private, the public etc... I check the github mailjet, the doc mailJet about the API without success. NSData *data = [NSData dataWithContentsOfFile:filePath]; NSLog(@"File Size: %lu",(unsigned long)[data length]); //set up request NSMutableURLRequest *request= [[NSMutableURLRequest alloc] init]; [request setURL:[NSURL URLWithString:@"https://api.mailjet.com/v3/send"]]; [request

How to add request Parameters in NSMutableRequest

丶灬走出姿态 提交于 2019-12-06 15:18:44
问题 I Have created a mutable request . NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; [request setHTTPMethod:@"POST"]; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; // I want to add a request parameter - Not in the header or body. Add Your code here // [request setHTTPBody:data]; Any one please help me 回答1: HOPE THIS WILL HELP YOU NSString *post=[NSString stringWithFormat:@

NSURLRequest setValue: forHTTPHeaderField:@“Authorization” not working

走远了吗. 提交于 2019-12-06 11:31:44
I try to make an authenticate call to the twitter API with the Application only Authentication API NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:20.0]; [request setHTTPMethod:@"POST"]; [request setValue:@"application/x-www-form-urlencoded;charset=UTF-8" forHTTPHeaderField:@"Content-Type"]; [request setValue:@"Some App Name" forHTTPHeaderField:@"User-Agent"]; [request setValue:authValue forHTTPHeaderField:@"Authorization"]; [request setHTTPBody:[@"grant_type=client_credentials"

NSMutableURLRequest “The request timed out” issue . .

筅森魡賤 提交于 2019-12-06 06:29:01
问题 I am trying to download data in my application by using the following code NSURL *url = [NSURL URLWithString:@"my download url string"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.f]; NSURLConnection * connection = [NSURLConnection connectionWithRequest:request delegate:self]; [connection start]; but the problem is some times i am getting the following error Error Domain=NSURLErrorDomain Code=-1001

User-Agent not changing in NSMutableURLRequest

心不动则不痛 提交于 2019-12-06 01:55:59
I know there may be several issues about this, but i´m facing a problem when i try to set a new "user agent" for my UIWebView . Here is what i am doing right now: NSURL *myUrl = [NSURL URLWithString:auxUrl]; NSMutableURLRequest *myRequest = [NSMutableURLRequest requestWithURL:myUrl]; NSMutableString *auxUserAgent = [[NSMutableString alloc] initWithString:[myRequest valueForHTTPHeaderField: @"User-Agent"]]; [auxUserAgent appendString:@"(iOS)"]; [myRequest setValue:auxUserAgent forHTTPHeaderField:@"User-Agent"]; NSLog(@"UA : %@",[myRequest valueForHTTPHeaderField: @"User-Agent"]); I am trying to

NSURLCache - Disk caching for GET request with parameters not working

*爱你&永不变心* 提交于 2019-12-05 05:49:44
问题 I'm trying to cache some HTTP requests to disk using NSURLCache. After doing some tests with AFNetworking and not working, I created a simple example using NSURLRequest. I initialize the cache on the AppDelegate like this, setting the memory size to 0, forcing it to go always to Disk: NSUInteger sz = 1024*1024*20; NSURLCache *cache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:sz diskPath:nil]; [NSURLCache setSharedURLCache:cache]; I use the following code to store the response:

Base64 Encoding for NSString [closed]

给你一囗甜甜゛ 提交于 2019-12-05 02:10:33
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I am trying to post the username and password to the server. I want to convert this username and password into Base64 Encoding. So