afnetworking

AFHTTPSessionManager header

强颜欢笑 提交于 2019-12-21 06:06:38
问题 I am trying to set a default header for "Content-Type" by setting HTTPAdditionalHeaders. When I look at the request header, AFNetworking (v 2.0.3) changes it back. I also tried to set header by setValue:forHTTPHeaderField: on the requestSerializer, but no success. What I am missing? UPDATED NSURL *URL = [NSURL URLWithString:@"http://example.com/api"]; NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; configuration.HTTPAdditionalHeaders = @{@

How can I use cookies using AFHTTPRequestOperationManager in AFNetworking 2.0+?

两盒软妹~` 提交于 2019-12-21 05:06:21
问题 As it is known, AFHTTPSessionManager in AFNetworking 2.0+ supports cookies. But is it possible for AFHTTPRequestOperationManager in AFNetworking 2.0+ to support cookies? 回答1: Yes. AFNetworking uses the foundation URL Loading system, which handles cookies out of the box. You can configure NSMutableURLRequest's setHTTPShouldHandleCookies and use NSHTTPCookieStorage to store them. In Objective-C: NSArray *cookieStorage = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:url];

multipart PUT request using AFNetworking

狂风中的少年 提交于 2019-12-21 04:19:08
问题 What's the correct way to code a multipart PUT request using AFNetworking on iOS? (still Objective-C, not Swift) I looked and seems like AFNetworking can do multipart POST but not PUT , what's the solution for that? Thanks 回答1: You can use multipartFormRequestWithMethod to create a multipart PUT request with desired data. For example, in AFNetworking v3.x: AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; NSError *error; NSURLRequest *request = [manager.requestSerializer

NSURLSession: background upload and then call a service api

梦想的初衷 提交于 2019-12-21 04:12:28
问题 I was trying to use the new ios7 background transfer api to upload some photos to a server. what it happened now is 1) we upload the bytes to s3 2) call a service api to 'complete' the upload i looked at this doc and it seems background NSURLSession doesn't support 'data' task. does that mean i can't do the step 2 in background after the actual upload is done? 回答1: If you want a simpler solution than repurposing NSURLSessionDownloadTask for your "completed" API call, you can round trip a

AFNetworking - Fade animation on image while scrolling UITableView

纵然是瞬间 提交于 2019-12-21 04:05:00
问题 I have a Table View which displays images using lazy loading from AFNetworking with a placeholder image. I'm trying to accomplish a way to fade from the placeholder to the image when it's loaded. My code here works, but if an image loads while scrolling the table, everything looks odd and the table stops scrolling. Same thing happens to a Horizontal scroller with the same effect. Here's the code I'm using inside cellForRowAtIndexPath [cell.hotelImage setImageWithURLRequest:[NSURLRequest

AFNetworking + cancelAllRequests

天大地大妈咪最大 提交于 2019-12-21 03:32:00
问题 I really have a problem when I want to stop all current requests in a sync engine built with AFNetworking. I have 5 different URL to query. Each query is launch if the previous was correctly executed. This works very well. I want to stop the sync process at anytime. So my code to do that is: - (void)cancelAllRequests { NSLog(@"CancelAllRequests"); [[HTTPClient sharedClient] cancelAllHTTPOperationsWithMethod:@"GET" path:@"ws/webapp/services/pull"]; [[HTTPClient sharedClient]

Multiple request with AFNetworking

左心房为你撑大大i 提交于 2019-12-21 02:33:10
问题 I'm trying to do multiple request in background to download many jsons and check data from them but I don't know how to use AFNetworking in that case. I tried to do like Wiki explaings but when it's going to download the second file then the app breaks. I want to do all the process in background. Thanks 回答1: AFNetworking will definitely handle this. We use it for exchanging data with a RESTful set of services. The things to keep in mind: An operation (eg. AFHTTPRequestOperation) can only be

RestKit and AFNetworking build error

白昼怎懂夜的黑 提交于 2019-12-20 20:28:03
问题 When I attempt to import the RestKit api into a project I get the following error: /Documents/Code/RestTest/RestKit/Code/Network/RKHTTPRequestOperation.h:21:9: 'AFNetworking.h' file not found I have installed RestKit as a git submodule, how do I resolve RestKit's dependency on AFNetworking? 回答1: Once cloned, simply do in the RestKit directory: git submodule update --init --recursive This will pull the AFNetworking version RestKit needs 回答2: If you use CocoaPods will do all this automaticaly.

AFNetworking fails to download large files

孤者浪人 提交于 2019-12-20 15:34:46
问题 I'm currently trying to download some files with AFNetworking, for relative small files this seems to work, but I'm trying a slighter larger file (17MB) and it seems to just crash without any error. The url is linking to a local file: http://test.local/wp-content/uploads/2012/07/test.pdf (I'm running it in the simulator, so this is accessible) The only output I get is in the progress block progress: 0.009022 When I check the filesystem, it appears that the file is there, but only a few kb. Is

AFNetworking + big download files + resume downloads

社会主义新天地 提交于 2019-12-20 10:13:33
问题 I need to download files > 500 Mo with AFNetworking. Sometimes, the time to download them is > 10 minutes and if the app is in background, the download can't be complete. So I want to try partial downloads. I found a lot of links and this seems to be possible with pause() and resume() methods on AFHTTPRequestOperation. Actually, I did: [self.downloadOperation setShouldExecuteAsBackgroundTaskWithExpirationHandler:^{ // Clean up anything that needs to be handled if the request times out [self