nsurlrequest

NSURLRequest http protocol version

自古美人都是妖i 提交于 2019-12-10 21:21:02
问题 It is quite a simple question from me today. Is it possible to set specific HTTP protocol version to NSURLRequest object (1.0 or 1.1, for example)? An example of what I'm talking about on telnet: pavlov:~ pavlov$ telnet ya.ru 80 Trying 87.250.250.3... Connected to ya.ru. Escape character is '^]'. GET /index.php HTTP/1.0 回答1: You cannot change the HTTP version of a NSURLRequest . However you can use the CFNetwork framework. It's the C framework on top of which NSURLConnection is based. The

In iOS, how to read the multi part form data in the NSURLRequest originating from a WKWebView?

拜拜、爱过 提交于 2019-12-10 17:24:34
问题 In our WKWebView, we have a multi part form POST request which we need to inspect and conditionally handle. Currently, we're trying this using the WKNavigationDelegate's webView:decidePolicyForNavigationAction:decisionHandler: method to gain access to the NSURLRequest. ( navigationAction.request ). But when we inspect the request here, we can verify that it is the multi part form POST, however, the [request HTTPBody] returns nil . 回答1: Unfortunately it is the bug in WebKit :(( : https://bugs

Correlate NSURLRequest with UIWebView

ぃ、小莉子 提交于 2019-12-10 14:47:14
问题 In iOS, I'd like to be able to associate an NSURLRequest -- any NSURLRequest , whether a navigation request or image or stylesheet request--with the UIWebView that sent it. This seems to call for the implementation of an NSURLProtocol subclass to capture and analyze requests as they come through. However, I can't find a way to correlate a request with its web view, and NSURLProtocol only seems to understand NSURLRequest s. This would be fine for navigation requests, as I could make the

Load UIImage from URL in iOS

人走茶凉 提交于 2019-12-10 13:44:00
问题 I am trying to load a UIImage from its URL with completion and placeholder image , but neither the UIImage nor the placeholder UIImage are loaded. Here is my code: NSURL *url = [NSURL URLWithString:@"http://assets.gearlive.com/tvenvy/blogimages/stewiegriffin.jpg"]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [self.imageView setImageWithURLRequest:request placeholderImage:[UIImage imageNamed:@"bg.png"] success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image)

Downloading multiple files writes same data to all files

点点圈 提交于 2019-12-10 11:42:40
问题 Attempting to download multiple files from an XML feed. There are several Categories and each category has an unknown amount of images. I create a subdirectory for each category, no problem. When I try to download each file to the respective category, every file is written with the same data for every image there is in the feed. I guess my question is how can I download 1 file at a time to the corresponding directory without overwriting all of the images with the same data? -(void

iPhone Objective C oauth 2.0 Login - unsupported_grant_type

雨燕双飞 提交于 2019-12-10 11:27:42
问题 I am brand new to salesforce development and am trying to connect to Salesforce to get the token. I guess my question is 2 fold: 1) Do I have to use a webpage to authenticate with SF? 2) If not, why is this not working? When I try to use the username and password method of authenticating, I get: {"error":"unsupported_grant_type","error_description":"grant type not supported"} Here is my code: NSString *post = [NSString stringWithFormat:@"grant_type=basic-credentials&client_id=%@&client_secret

NSUrlRequest from curl for stripe

被刻印的时光 ゝ 提交于 2019-12-10 10:04:06
问题 I need to make a http post request using the following instructions: curl https://api.stripe.com/v1/tokens \ -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \ -d "bank_account[country]=US" \ -d "bank_account[routing_number]=110000000" \ -d "bank_account[account_number]=000123456789" I have no idea how to go from curl to NSUrlrequest, especially the -u (user?) part. The stripe SDK has left this out from their SDK and has no example on their site. Thanks 回答1: EDIT:I created another answer specifically for

NSURLSession delegate methods not called

不问归期 提交于 2019-12-10 09:28:18
问题 I have created a very simple app to download a text file from my web server. I have this working perfectly with NSURLConnection, but am trying to migrate over to NSURLSession instead. The issue I am having is that none of the delegate methods are being called. My server is password protected so I need to use the basic http authentication to access the file, but when the didReceiveChallenge method is never called. The line of code [getFileTask resume] seems to have no effect on anything. My

How to retry a block based URL Request

耗尽温柔 提交于 2019-12-10 01:36:45
问题 I am fetching data using iOS7's new URL request methods, like so: NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[self.baseUrl stringByAppendingString:path]]]; NSURLSessionDataTask *dataTask = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response; NSUInteger responseStatusCode = [httpResponse statusCode]; if

Set UILabel text within code block

大兔子大兔子 提交于 2019-12-09 23:37:50
问题 I have a code block for my NSURLConnection sendAsynchronousRequest, and when I try to set a UILabel's text, the text is never set, even though the values are there. Here's my code: NSString *address = [addresses objectAtIndex:indexPath.row]; NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://myurl.com/%@", address]]]; [NSURLConnection sendAsynchronousRequest:urlRequest queue:[[NSOperationQueue alloc] init] completionHandler:^