nsurlrequest

How to insert header info into MPMoviePlayerController url?

匆匆过客 提交于 2019-11-29 02:45:07
I need to implement video streaming service with http protocol. I know how to set url into MPMoviePlayerController, and how to set headerField into NSMutableURLRequest, but I have no idea how to combine them. I implement like below code, but not working, and I assume because there is no file info in the binary data. - (void) openUrl { NSMutableURLRequest *reqURL = [NSMutableURLRequest requestWithURL: [NSURL URLWithString:@"http://111.222.33.44/MOV/2013/4/123123123"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0]; [reqURL setHTTPMethod:@"GET"]; [reqURL setValue:@"Mozilla/4

iOS any body knows how to add a proxy to NSURLRequest?

ε祈祈猫儿з 提交于 2019-11-28 21:46:02
问题 I'm setting up a webview but I need to load the content of the webview using a proxy. Any of you knows how can I'm implement the proxy in NSURLRequest? for example: NSString *location=@"http://google.com"; NSURL *url=[NSURL URLWithString:location]; NSURLRequest *request=[NSURLRequest requestWithURL:url]; // some code to set the proxy [self.myWebView loadRequest:request]; I'll really appreciate your help 回答1: Take a look at iOS URL Loading System as well as NSURLProtocol You can write a custom

NSURLConnection leak?

孤街醉人 提交于 2019-11-28 18:28:17
i have set up a nsurl which grabs the data from http. when i run instrument, it says i have a leak NSFNetwork object. and how do i release theConnection in (void)ButtonClicked? or it will be release later on? - (void)ButtonClicked { NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:KmlUrl] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0f]; NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if (theConnection) { // receivedData is declared as a method instance elsewhere NSMutableData *receivedData =

How do I make HTTP post request for getting JSON object in response for iPhone application?

佐手、 提交于 2019-11-28 18:27:25
I've a web service running on server which return data either in XML format or JSON format. I wanted to request a JSON format but using HTTP Post method. any help greatly appreciated. thanks in advance. This is the code which work for JSON post request, TouchJSON Framework is used for parsing the JSON, thanks 'schwa'. NSArray *keys = [NSArray arrayWithObjects:@"username", @"password", @"preference", @"uid", nil]; NSArray *objects = [NSArray arrayWithObjects:@"accuser", @"accpass", @"abc_region", @"100", nil]; NSDictionary *theRequestDictionary = [NSDictionary dictionaryWithObjects:objects

How can I set the “User-Agent” header of a UIWebView in Swift

蹲街弑〆低调 提交于 2019-11-28 18:21:09
I am using Xcode 6 for an iOS App with Swift. I have got a simple ViewController with an embedded UIWebView. You can find the code below. Now I want to change the User-Agent HTTP header. I tried to use the setValue method of NSURLRequest but it didn't work (see uncommented line). Does anyone know how to do that? import UIKit class WebViewController: UIViewController { @IBOutlet weak var webView: UIWebView! override func viewDidAppear(animated: Bool) { var url = NSURL(string: "https://www.samplepage.com") var request = NSMutableURLRequest(URL: url) // request.setValue("Custom-Agent",

Use a self-signed ssl certificate in an iphone app

扶醉桌前 提交于 2019-11-28 15:15:16
I apologize in advance for the long-winded question. I'm having trouble with a self-signed SSL cert and I want to document everything I've tried so far. I'm working on an app that communicates with a REST service. The test server uses a self-signed ssl certificate that I can install on my computer without issue. It's a .p12 file that requires a password to install. Without this certificate installed, all requests to the server return a 403. The .p12 installs three items in the Keychain, a "Root certificate authority", a "test user" certificate that's issued by the "Root certificate authority",

Swift 2.0 NSURLConnection sendSynchronousRequest

ぃ、小莉子 提交于 2019-11-28 13:04:49
I am using the code below to check for an internet connection. It was working correctly but after the Swift 2.0 update I now see an error on the line var data = NSURLConnection.sendSynchronousRequest(request, returningResponse: &response, error: nil) as NSData? saying extra argument 'error' in call. class func isConnectedToNetwork()->Bool{ var Status:Bool = false let url = NSURL(string: "http://google.com/") let request = NSMutableURLRequest(URL: url!) request.HTTPMethod = "HEAD" request.cachePolicy = NSURLRequestCachePolicy.ReloadIgnoringLocalAndRemoteCacheData request.timeoutInterval = 10.0

converting image to base64 and uploading in JSON format to server

孤人 提交于 2019-11-28 11:25:45
问题 I have a problem. I need to convert base64 string to JSON string and pass it to server. for example I have a base64 string /9j/4AAQSkZJRgABAQAAAQABAAD/4QBYRXhpZgAATU0AKgAAAAgAAgESAAMAAAABAAEAAIdpAAQAAAABAAAAJgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAACqADAAQAAAABAAAACgAAAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/Z i need to convert it to JSON format. I do the following: +(NSData *)prepareForUploading:(NSString *)base64Str { NSDictionary *dict=

HTTPS Service is not working

守給你的承諾、 提交于 2019-11-28 10:06:22
问题 I want to login by using web service. My website is https based. I am using following tutorial. http://agilewarrior.wordpress.com/2012/02/01/how-to-make-http-request-from-iphone-and-parse-json-result/ Following code is working fine. responseData = [NSMutableData data]; NSURLRequest *request = [NSURLRequest requestWithURL: [NSURL URLWithString:@"https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key

Is there any way to attach a NSDictionary of parameters to an NSURLRequest instead of manually making a string?

守給你的承諾、 提交于 2019-11-28 07:02:56
问题 AFNetworking allows you to add an NSDictionary of parameters to a request, and it will append them to the request. So if I wanted to do a GET request with ?q=8&home=8888 I'd just making an NSDictionary like @{@"q": @"8", @"home": @"8888"} very simply. Is there a way to do this with NSURLSession / NSURLConnection / NSURLRequest ? I know I can use NSJSONSerialization for appending JSON data, but what if I just want them as GET parameters in the URL? Should I just add a category? 回答1: You can do