Questions tagged [nsurlprotocol]

NSURLProtocol is an abstract class that provides the basic structure for performing protocol-specific loading of URL data.

NSURLProtocol is available in iOS 2.0 and later with iOS and available in OS X v10.2 with Safari 1.0 installed ,available in OS X v10.2.7 and later with OSX.

An NSURLProtocol object handles the loading of protocol-specific URL data. The NSURLProtocol class itself is an abstract class that provides the infrastructure for processing URLs with a specific URL scheme. You create subclasses for any custom protocols or URL schemes that your app supports.

Apps never need to instantiate an NSURLProtocol subclass directly. When a download starts, the system creates the appropriate protocol object to handle the corresponding URL request. All you have to do is define your protocol class and call the registerClass: class method during your app’s launch time so that the system is aware of your protocol.

Source : NSURLProtocol Class Reference

NOTE

You cannot use this class to define custom URL schemes and protocols in watchOS 2 and later.
142 questions
0
votes
1 answer

How to disable caching when using custom NSURLProtocol?

I've got an app with UIWebView which is used to load local files. I've created a custom URL protocol, which I use to do some stuff with the data passed to the web view, and in startLoading I've added: [self.client URLProtocol:self…
Krystian
  • 3,193
  • 2
  • 33
  • 71
0
votes
2 answers

Preventing NSURLProtocol implementations to read URLs

We have developed an iOS framework to be distributed to other developers to use in their apps and make use of some services we would provide. It works great (in vitro). But, because of the way URL Loading System works in iOS, with a few line of…
M. Porooshani
  • 1,797
  • 5
  • 34
  • 42
0
votes
1 answer

Test that NSURLSessionConfiguration settings are obeyed

I created an NSURLSessionConfiguration with some default settings but when I see the request object made with that configuration in my custom NSURLProtocol it doesn't seem that all those settings are inherited and I'm a bit…
wesshi
  • 231
  • 2
  • 11
0
votes
1 answer

Separate call inside startLoading in NSURLProtocol

I am trying to make a separate http call inside startLoading() before submitting the original request. Code is like below : +canInitWithRequest(){ if(self.request.valueForKey("handledKey") != nil){ return false; } return…
Rao
  • 51
  • 7
0
votes
1 answer

iOS Swift how to tell the UIView Controller that we received information via a NSURLProtocol object

I created a class that implements NSURLProtocol which will tells me about the UIWebView requests. I am looking to tell the UI that we hit a URL of interest and run code back on the ViewController to access the WebView. I believe Protocols are the…
user516883
  • 8,868
  • 23
  • 72
  • 114
0
votes
1 answer

Network traffic from a iOS SDK

Let's say I want to build a SDK that communicates with a server. I don't want any one (not even the app that implements the SDK) to intercept and look at my requests/responses. If I'd use a common lib like AFNetworking it would be possible to look…
johan
  • 6,578
  • 6
  • 46
  • 68
0
votes
1 answer

Regestring NSRULProtocol for NSURLSessions Globally

I am trying to use NSURLProtocol to handle authentication challenges for every NSURLSession connection . I used [NSURLProtocol registerClass:[CustomHTTPSProtocol class]] for NSURLConnection .But it is not working with NSURLSession so i need to…
vishnuvarthan
  • 492
  • 1
  • 6
  • 23
0
votes
0 answers

Proxy server persistent connection closing

I'm implementing proxy support for an osx app. I've created a custom NSURLProtocol and it is working perfectly for a proxy without authentication. Tried with both CCProxy and FreeProxy on a Windows computer in the local network. However when proxy…
Templar
  • 1,694
  • 1
  • 14
  • 32
0
votes
0 answers

How is NSURL "copied" during URL loading?

I'm writing a subclass of NSURL (along with a partnering subclass of NSURLProtocol). I'm intentionally stashing an additional data property on the URL object intended to be retrieved and used in the URL loading. (This is just an experiment; don't…
Ben Zotto
  • 70,108
  • 23
  • 141
  • 204
0
votes
0 answers

NSURLProtocol Timing out too fast

I have observed that some time StopLoading is getting called within a second . Its not giving enough time to serve the request. Has anyone else has encountered similar behavior before? IS there any solution to this problem?
iOSMonkey
  • 119
  • 1
  • 1
  • 9
0
votes
1 answer

Video streaming in MPMoviePlayerController embedded in UIWebView

I want to know that how networking streaming is performed in MPMoviePlayerController embedded in UIWebView in iOS. Is it performed using sockets or any other approach? Firstly please understand my problem, I am playing youtube videos in UIWebView.…
0
votes
0 answers

NSURLProtocol requestIsCacheEquivalent:toRequest showing a trailing slash

I'm investigating cache hits and misses on my own subclass of NSURLProtocol. I have a request that looks like this (from a UIWebView) https://www.my.server/?myqueryParams For now, I am using simple string comparisons on the URLs: +…
Ben Flynn
  • 18,524
  • 20
  • 97
  • 142
0
votes
2 answers

NSURLProtocol & swift - error in ios7

I tried to implement a NSURLProtocol as explained in the following tutorial: http://www.raywenderlich.com/76735/using-nsurlprotocol-swift Everything works fine with iOS8 but in iOS7 I get a runtime error in startLoading(). override func…
Reinhold
  • 234
  • 2
  • 10
0
votes
1 answer

iOS NSURLCache making up HTTP 404 when going through NSURLProtocol

If you are serious about answering this question, please clone the mini app i have created and see if it misbehaves for you the same way, before speculating about the answer, thank you :) https://github.com/pavel-zdenek/nsurlprotocol-testbed A very…
Pavel Zdenek
  • 7,146
  • 1
  • 23
  • 38
0
votes
1 answer

NSURLProtocol SWIFT error

I am trying to implement an NSURLProtocol in my app that will fetch URLs starting with myApp://... I created the Protocol in a new SWIFT file and implemented in the AppDelegate: func application(application: UIApplication,…
Tosen
  • 76
  • 1
  • 5
1 2 3
9
10