nsurlconnection

Always getting back cached data in NSURLSessionDataTask

允我心安 提交于 2019-12-05 13:00:54
I'm facing a very strange issue when using NSURLSessionDataTask to post a JSON request to the server. The first request goes through and I receive the correct JSON response, when I do a second request I'm getting always back the old response and the server never receives the request. Even if I turn on airplane mode the NSURLSessionDataTask does work an I get back the old response again. That's the code I'm using: - (void)getJSONFromURL:(NSURL*)url identifierCode:(NSInteger)code { NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession

NSURLCache Memory Size is zero

随声附和 提交于 2019-12-05 12:31:32
I am having trouble caching NSURLConnection responses using a synchronous call. I initialize the cache in one class and then use it in another. Notice how the cache memory capacity gets initialized to 100KB but then is magically reset to zero later. - (id)init { if (self = [super init]) { // Creates a custom URL cache that uses both memory and disk. NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:kMemoryCacheSize * 1000000 diskCapacity:kDiskCacheSize * 1000000 diskPath:diskPath]; [NSURLCache setSharedURLCache:sharedCache]; NSLog(@"Cache memory capacity = %d bytes", [

HTTPS POST from iPhone using NSURLConnection hangs for certain filesize range

情到浓时终转凉″ 提交于 2019-12-05 11:40:55
I'm using NSURLConnection to make an async HTTPS POST to our webservice to upload a jpg. It works fine most of the time. But when the post body is between 196609 and 196868 bytes (inclusive), the connection hangs after the file has been uploaded 100% (didSendBodyData tells me that it's 100% sent). Then after 5 minutes, the connection times out with the message "The network connection was lost." Larger and smaller filesizes work. I've tested this by capping the filesize of the file that I add to the post body. The content length is getting set correctly. See the code below. The upload looks

NSURLConnection IOS 3G issue

99封情书 提交于 2019-12-05 11:07:49
I have used NSURLConnection (asynchronous) in my app which is working fine on wifi (iOS5 & iOS6). But its creating an issue with 3G. When I run my app 3G connection then I dont get any data in my didReceiveData method. I have putted logs in my delegate methods, but while using 3G, The request is getting timed out. What can be the issue. EDIT: On server side -> It shows that my request has been sent to server & server has also sent the response to the client. EDIT 2: The code which I have written is as follows. NSURL *url = [NSURL URLWithString:@"someURL"]; NSMutableURLRequest *req = [

iOS NSURLConnection not downloading files from certain URLs

情到浓时终转凉″ 提交于 2019-12-05 08:19:59
I have an NSURLConnection in a tableview cell subclass that can download most files. I noticed, however, that some fail to start downloading, and time out. An example would be this URL, which is just a test zip file that downloads fine in any other browser. Heres my code for the download -(void)downloadFileAtURL:(NSURL *)url{ self.downloadedData = [[NSMutableData alloc] init]; self.url = url; conn = [[NSURLConnection alloc] initWithRequest:[NSURLRequest requestWithURL:self.url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:1200.0] delegate:self startImmediately:YES]; } - (void

How to get image from server using NSUrlConnection [duplicate]

依然范特西╮ 提交于 2019-12-05 08:16:22
问题 This question already has answers here : iOS: Download image from url and save in device (9 answers) Closed 6 years ago . How to get image from server by sending one parameter with url. GET HTTPRequest has to be use to send request. 回答1: You can get image from server with specific path of that image with image name. UIImage* serverImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString: @"http://example.com/image_name.png"]]]; then you can use serverImage anywhere

XCode webview connection/server error handling

安稳与你 提交于 2019-12-05 08:00:51
问题 All, I am fairly new to XCode and am trying to get a handle on how to best deal with connection issues when trying to use a WebView. I know there are related questions on SO, but none seem to offer complete solutions. I have the following code, but it seems a little inefficient. Hopefully, someone can help me refactor it down to a point where it can be usable anywhere that a UIWebView is called. NOTE: Please ignore memory issues for now. I realize that has to be added as well. - (void

How many urlRequests are handled by nsurlconnection

扶醉桌前 提交于 2019-12-05 07:51:49
问题 I have to call 20 urlReqests at a time after going through many websites i have found that 4 urlRequsts are handled after that next undergoing requests will encounter error that is timeout error.when i call 5 webservices in a loop first 4 webservices are executing and 5th gets timeout error.How to handle this situation Any help would be appreciated 回答1: You can use NSOperationQueue for such tasks. Here is the sample code- Code for RequestManager.h :- #import <Foundation/Foundation.h>

UIWebView doesn't load images from protocol-relative URL

我的未来我决定 提交于 2019-12-05 07:15:57
Make an app with UIWebView which open a webpage with protocol-relative styles & images, such as <img src="//example.com/image.png"> (examples for http or https ). Override the page loading process via your custom NSURLConnection , this way . Result: it won't display the images! Though, Safari and other browsers show them correctly... I inspected the page opened in WebView and saw weird requests there. They looked like regular URLs, but with applewebdata scheme, e.g. applewebdata://art-u1.infcdn.net/articles_uploads/2/2586/thumb/3Dtouch%20Main-665x.png . Yay! It doesn't know the "base" scheme

Using a proxy for NSURLConnection

雨燕双飞 提交于 2019-12-05 07:02:29
Is there any way to get the content of a webfile (namely a .html Document) using a proxy, which is not defined in the system settings? I know that NSURLConnection is the right way to download a web file into a variable and not into a file (for which we should use NSURLDownload), but I don't find a way to use a proxy for it. Are there some unofficial APIs, Libraries or Classes or such I could use for what I want to do? I'm not that pro in Mac Programming, so I'm searching for something more or less simple. SideSwipe NSURL classes wont do this. You need to drop down to CFURL . From mailing list: