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

UIWebView + NSUrlConnection - LinkedIn stuck in an Infinite Loop

I'm trying to create a WebView App on iOS to intercept all URL requests for some logging purposes. For this, I wrote a class that extends NSUrlProtocol & and loads requests using NSUrlConnection following this…
0
votes
1 answer

iOS:[NSURLProtocol propertyForKey:inRequest:] return nil

While playing with NSURLProtocol, I found [NSURLProtocol propertyForKey:inRequest:] always return nil in stopLoading, but work well for canInitWithRequest: + (BOOL)canInitWithRequest:(NSURLRequest *)request { if ([NSURLProtocol…
keywind
  • 1,135
  • 14
  • 24
0
votes
1 answer

how to add a prxoy server to my http requests via NSURLProtocol?

I need to proxy all my app's http and https requests trought a proxy server. I cannot just change the url because most of the requets are done via 3rd party libs. I tried some code from: iOS any body knows how to add a proxy to NSURLRequest? but it…
João Nunes
  • 3,751
  • 31
  • 32
0
votes
3 answers

Why won't startLoading be called in my NSURLProtocol subclass?

I am looking at NSURLProtocol and am trying to insert some headers. - (void)startLoading { NSMutableURLRequest *newRequest = [self.request mutableCopy]; [NSURLProtocol setProperty:@YES forKey:kAccessCodeProtocolKey inRequest:newRequest]; …
jimijon
  • 2,046
  • 1
  • 20
  • 39
0
votes
1 answer

NSURLProtocol canInitWithRequest calling 5 times

I'm working on a hybrid application framework. I needed to catch all request from somewhere and i fond some blog it says i can do that with using custom NSURLProtocol. I did everything it says but i have some problems. When i load…
WeyCell
  • 273
  • 1
  • 2
  • 12
0
votes
1 answer

Why is there no NSHTTPURLProtocol class?

Well, NSURLProtocol is pretty generic right? It is for defining all kinds of protocols, isn't it? So why is there nothing like NSHTTPURLProtocol? Instead, there is an informal category on NSURLRequest with specific HTTP stuff. Why did they do that…
openfrog
  • 40,201
  • 65
  • 225
  • 373
0
votes
2 answers

Calling an instance method when subclassing NSURLProtocol

So I've had to subclass NSURLProtocol because I am using a UIWebView and want to intercept ajax calls which works fine as per this example. I have to get the data from the request from + (BOOL)canInitWithRequest:(NSURLRequest *)request which causes…
Rudiger
  • 6,749
  • 13
  • 51
  • 102
1 2 3
9
10