nsurlrequest

How to upload an array to a WebService

…衆ロ難τιáo~ 提交于 2019-12-12 02:25:35
问题 I'm having some doubts about how to upload something to a WebService. I've been using this for getting info from my webservice: NSString * URLString = [NSString stringWithFormat:@"%@%@", kBaseHost, [NSString stringWithFormat:kWSProjectList, token]]; NSURL *url = [NSURL URLWithString:URLString]; NSURLRequest * request = [NSURLRequest requestWithURL:url]; [NSURLConnection sendSynchronousRequest:request inBackgroundWithCompletionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {

Network connection was lost NSURLConnection

这一生的挚爱 提交于 2019-12-11 20:54:16
问题 This error is printed every time I attempt a connection. No idea why it cant connect to the server. Built a simple java application and it worked fine. Ive been surfing StackOverflow for days trying to figure this out. Tried multiple API's and somethings just not right. If you need more code, or have any further questions let me know. Please help. :( 2013-08-29 21:56:55.946 panic[15054:70b] Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo=0xa779a30

download files using http request in background in iPhone (above iOS 4.0)

无人久伴 提交于 2019-12-11 17:58:31
问题 I am new to iOS. I want to know some basic need for my application is possible or not? "When my application starts (tapping on my application icon), app should download some 5-10 files from server. It should continue its downloading in background also if "Home" button is pressed. And my app has retry logic i.e. if server is unreachable and request timeout occurred then app will wait for some time and send request again and again till downloading completed." Is it possible? 回答1: So what you

Network API to return HTTPS response in iPhone

陌路散爱 提交于 2019-12-11 16:00:17
问题 Can I return the server response from any function to its calling function using any of the Network API like AFNetworking, MKNetworkKit etc, in iPhone. Currently I am using httpGet function of NSURLRequest. I made the following function but I am not able to return the server response to it calling function. Please help me. func connserv(jsonString:NSDictionary) -> NSDictionary{ var abc: NSDictionary? // This is the action performed when clicked on the Connect button on the connectivity screen

Swift: How to add Dictionary format in forHTTPHeaderField in GET request

拟墨画扇 提交于 2019-12-11 15:59:11
问题 In GET request, I am trying to add header. request.setValue(value: String?, forHTTPHeaderField: "SessionInfo") But, SessionInfo value is in [String : Any] Attempt 1: func SO_Function() { let service_url = WebService.sharedManager().serviceURL let getMenuURL = service_url + "/MyPage/FileDownload.ashx" var convertedString = "" do { let data1 = try JSONSerialization.data(withJSONObject: WebService.sharedManager().mobInfoDict, options: []) convertedString = String(data: data1, encoding: .utf8)!

Get remote file size via HTTP without downloading said file

眉间皱痕 提交于 2019-12-11 14:45:07
问题 Any way to get the size of a (remote, http) file without actually downloading it? All other similar questions seem to revolve around grabbing the expectedContentLength from the NSURLResponse object in didReceiveResponse: but I don't want to download the file, I just want to know how big it is. 回答1: Try to make HEAD request, it returns only headers with Content-Length header included. ~$ curl -I http://google.com/ HTTP/1.1 301 Moved Permanently Location: http://www.google.com/ Content-Length:

How to Send Multiple File as attachment in Multipart Forms [HTTP POST Request]

白昼怎懂夜的黑 提交于 2019-12-11 13:16:32
问题 I am near to ultimate my app, and the final step is to implement a feature where I need to send multiple files to one message. Also I would like to imitate Mail attachment behavior like pict. i have achieve this Instead, for sending multiple file I have one problem: only first file appears on received message; the others was lost. So please look my code, especially the cycle loop, for possible mistake and or suggestion. Thank you for your time. - (IBAction)simple3:(id)sender{ NSLog(@"The

objective-c, possible to queue async NSURLRequests?

别来无恙 提交于 2019-12-11 09:15:24
问题 I realize this question sounds contradictory. I have several Async requests going out in an application. The situation is that the first async request is an authentication request, and the rest will use an access token returned by the successful authentication request. The two obvious solutions would be: run them all synchronous, and risk UI block. (bad choice) run them async, and put request 2-N in the completion handler for the first one. (not practical) The trouble is that the subsequent

Http live streaming: Forcing MPMoviePlayerController to pack headers in the http requests

会有一股神秘感。 提交于 2019-12-11 04:46:55
问题 I am streaming video from a server to iPhone using Http Live Streaming. I need to set certain headers in the http packets that the phone sends to the server. For regular packets, the following code would suffice: NSMutableURLRequest* request = [[[NSMutableURLRequest alloc] initWithURL:url] autorelease]; [request setValue:VALUE forHTTPHeaderField:@"Field You Want To Set"]; Unfortunately, I did not find a similar API for MPMoviePlayerController . In other words, how do I force

NSURLConnection failure - 1003

喜欢而已 提交于 2019-12-10 23:19:07
问题 I try to retrive data from certain url with command: -(NSMutableData *) callUrl: (NSString *)url withData:(NSMutableDictionary *)data delegate:(id) delegate { NSURL *executeUrl = [NSURL URLWithString:<string>]; NSURLRequest *request = [NSURLRequest requestWithURL: executeUrl cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60]; NSMutableData *receivedData = nil; NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:delegate]; if