nsurlprotocol

AVPlayer URL custom loading for HTTPS

倖福魔咒の 提交于 2020-06-17 09:14:30
问题 I'm trying to use AVPlayer with custom URL loading (a custom NSURLProtocol subclass). But it seems [NSURLProtocol registerClass] does not work with AVPlayer in real device (see this thread). Now I'm trying to use AVAssetResourceLoaderDelegate to do the custom URL loading. However it is a bit confusing to me how the delegate will be triggered. The URL I deal with looks like this https://some_ip_address:port/resource/ , but it seems like my delegate is not called for such URL. I tried to change

NSURLProtocol registerClass works for iOS simulator but not actual device

∥☆過路亽.° 提交于 2020-03-16 07:38:09
问题 I am calling [NSURLProtocol registerClass] to use a custom protocol (Chromium Cronet) when playing a video using AVPlayer . (The register is done at here: ) It works well on iOS simulator (Xcode 11.3) but when runs on an actual device (iPhone SE, iOS 13), the custom protocol was not triggered. (i.e. it's canInitWithRequest method was not called). My question: what is the possible reason to cause different behavior between iOS simulator and real device in the case of [NSURLProtocol

How to intercept a WKWebView request to detect which local resource files (css, js, png, …) load together with a HTML file?

二次信任 提交于 2020-02-22 04:17:12
问题 I have a HTML file which contains local resource files such as css, js and png files inside its content. These local resource files are in zip format. My app use WKWebView to display this html file. I want to find a solution to intercept the web view request to detect which local resource files are load together with this html file -> then unzip them if they are still zip format. My HTML data content contains thousands of these local resource file so I can't unzip all of them before display

Handling redirects with custom NSURLProtocol and HTTP proxy

你。 提交于 2020-01-12 06:12:07
问题 I have a custom URLProtocol where I want to redirect all traffic via a proxy server. My current working code looks like that: +(BOOL)canInitWithRequest:(NSURLRequest*)request { if ([NSURLProtocol propertyForKey:protocolKey inRequest:request]) return NO; NSString *scheme = request.URL.scheme.lowercaseString; return [scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"]; } -(void)startLoading { NSMutableURLRequest *request = self.request.mutableCopy; [NSURLProtocol setProperty:

NSURLProtocol - handle https request

纵饮孤独 提交于 2020-01-05 12:28:06
问题 This is canInitWithRequest in NSURLProtocol : + (BOOL)canInitWithRequest:(NSURLRequest *)request { // only handle http requests we haven't marked with our header. if ([[[request URL] scheme] isEqualToString:@"http"] && ([request valueForHTTPHeaderField:RNCachingURLHeader] == nil)) { return YES; } return NO; } But I want NSURLProtocol to allow https requests as well. I tried this but all requests fail when called : + (BOOL)canInitWithRequest:(NSURLRequest *)request { // only handle http

Subclassing URLProtectionSpace

ε祈祈猫儿з 提交于 2019-12-23 04:57:24
问题 Aim: Test SSL pinning by using URLProtocol. Problem: Cannot subclass URLProtectionSpace in the expected manner. The server trust property is never called and the alamofire auth callback only receives a URLProtectionSpace class type instead of my class even though the initializer of my custom class gets called. Configuration: [using Alamofire] let sessionConfiguration: URLSessionConfiguration = .default sessionConfiguration.protocolClasses?.insert(BaseURLProtocol.self, at: 0) let

Is there a way to use NSURLProtocol in a NSURLSession with custom config?

邮差的信 提交于 2019-12-21 12:59:24
问题 I have a NSURLSession that runs in a background queue. I'm adding my NSURLProtocol subclass to the NSURLsessionConfiguration.protocolClases but the override class func canInitWithRequest(request: NSURLRequest) -> Bool never gets called. This is how I'm adding my NSURLProtocol let configuration = NSURLSessionConfiguration.defaultSessionConfiguration() configuration.protocolClasses!.append(MockNetwork) urlSession = NSURLSession(configuration: configuration, delegate: self, delegateQueue:

Using a custom NSURLProtocol with UIWebView and POST requests

僤鯓⒐⒋嵵緔 提交于 2019-12-18 20:02:20
问题 In my iOS app, I'm using a UIWebView and a custom protocol (with my own NSURLProtocol implementation). I've been fairly careful about making sure that whenever I load a url, I load something like this into my UIWebView: myprotocol://myserver/mypath and in my NSURLProtocol implementation, I take a mutable copy of the NSURLRequest, convert the URL to http: and send that to my server. Everything works for HTTP GET requests. The problem I encounter is with POST requests. It seems like the

Passing data to objective c with POST rather than GET

落爺英雄遲暮 提交于 2019-12-18 12:04:45
问题 I have been using the url intercept method to pass data from javascript to objective C by passing the data as url encoded parameters and using NSURLProtocol to intercept the request however I am now wanting to send larger amounts of data like say 10,000 character long strings but this does not seem practical to do in a GET request. Right? Is there a way for objective c to intercept POST data sent from a UIWebView? If so do I still use NSURLProtocol and how do I get the POST data? If not is

Possible to play video using a subclass of NSURLProtocol, using either MPMovieController or AVFoundation?

孤者浪人 提交于 2019-12-18 01:20:31
问题 I'm currently trying to play a video to a URL that has the custom scheme defined in a custom NSURLProtocol subclass. Initially I was using MPMoviePlayerController in an attempt to accomplish this, but after running into problems and checking stack overflow, I found that the MPMoviePlayerController does not handle NSURLProtocol subclasses as expected. How to play movie with a URL using a custom NSURLProtocol? As a result I decided to look at the AVFoundation framework, however, it seems that