Class: NSURLProtocol
Overview
NSURLProtocol is an abstract class that provides the basic structure for performing protocol-specific loading of URL data. Concrete subclasses handle the specifics associated with one or more protocols or URL schemes.
Class Method Summary (collapse)
-
+ canInitWithRequest:
Returns whether the protocol subclass can handle the specified request.
-
+ canonicalRequestForRequest:
Returns a canonical version of the specified request.
-
+ propertyForKey:inRequest:
Returns the property associated with the specified key in the specified request.
-
+ registerClass:
Attempts to register a subclass of NSURLProtocol, making it visible to the URL loading system.
-
+ removePropertyForKey:inRequest:
Removes the property associated with the specified key in the specified request.
-
+ requestIsCacheEquivalent:toRequest:
Returns whether two requests are equivalent for cache purposes.
-
+ setProperty:forKey:inRequest:
Sets the property associated with the specified key in the specified request.
-
+ unregisterClass:
Unregisters the specified subclass of NSURLProtocol.
Instance Method Summary (collapse)
-
- cachedResponse
Returns the receiver’s cached response.
-
- client
Returns the object the receiver uses to communicate with the URL loading system.
-
- initWithRequest:cachedResponse:client:
Initializes an NSURLProtocol object.
-
- request
Returns the receiver’s request.
-
- startLoading
Starts protocol-specific loading of the request.
-
- stopLoading
Stops protocol-specific loading of the request.
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Class Method Details
+ (Boolean) canInitWithRequest(request)
Returns whether the protocol subclass can handle the specified request. A subclass should inspect request and determine whether or not the implementation can perform a load with that request.This is an abstract method and subclasses must provide an implementation.
+ (NSURLRequest) canonicalRequestForRequest(request)
Returns a canonical version of the specified request. It is up to each concrete protocol implementation to define what “canonical” means. A protocol should guarantee that the same input request always yields the same canonical form.Special consideration should be given when implementing this method, because the canonical form of a request is used to lookup objects in the URL cache, a process which performs equality checks between NSURLRequest objects.This is an abstract method and subclasses must provide an implementation.
+ (Object) propertyForKey(key, inRequest:request)
Returns the property associated with the specified key in the specified request. This method provides an interface for protocol implementors to access protocol-specific information associated with NSURLRequest objects.
+ (Boolean) registerClass(protocolClass)
Attempts to register a subclass of NSURLProtocol, making it visible to the URL loading system. When the URL loading system begins to load a request, each registered protocol class is consulted in turn to see if it can be initialized with the specified request. The first NSURLProtocol subclass to return YES when sent a canInitWithRequest: message is used to perform the URL load. There is no guarantee that all registered protocol classes will be consulted.Classes are consulted in the reverse order of their registration. A similar design governs the process to create the canonical form of a request with canonicalRequestForRequest:.
+ (Object) removePropertyForKey(key, inRequest:request)
Removes the property associated with the specified key in the specified request. This method is used to provide an interface for protocol implementors to customize protocol-specific information associated with NSMutableURLRequest objects.
+ (Boolean) requestIsCacheEquivalent(aRequest, toRequest:bRequest)
Returns whether two requests are equivalent for cache purposes. The NSURLProtocol implementation of this method compares the URLs of the requests to determine if the requests should be considered equivalent. Subclasses can override this method to provide protocol-specific comparisons.
+ (Object) setProperty(value, forKey:key, inRequest:request)
Sets the property associated with the specified key in the specified request. This method is used to provide an interface for protocol implementors to customize protocol-specific information associated with NSMutableURLRequest objects.
+ (Object) unregisterClass(protocolClass)
Unregisters the specified subclass of NSURLProtocol. After this method is invoked, protocolClass is no longer consulted by the URL loading system.
Instance Method Details
- (NSCachedURLResponse) cachedResponse
Returns the receiver’s cached response. If not overridden in a subclass, this method returns the cached response stored at initialization time.
- (Object) client
Returns the object the receiver uses to communicate with the URL loading system.
- (Object) initWithRequest(request, cachedResponse:cachedResponse, client:client)
Initializes an NSURLProtocol object. Subclasses should override this method to do any custom initialization. An application should never explicitly call this method.This is the designated intializer for NSURLProtocol.
- (NSURLRequest) request
Returns the receiver’s request.
- (Object) startLoading
Starts protocol-specific loading of the request. When this method is called, the subclass implementation should start loading the request, providing feedback to the URL loading system via the NSURLProtocolClient protocol.Subclasses must implement this method.
- (Object) stopLoading
Stops protocol-specific loading of the request. When this method is called, the subclass implementation should stop loading a request. This could be in response to a cancel operation, so protocol implementations must be able to handle this call while a load is in progress. When your protocol receives a call to this method, it should also stop sending notifications to the client.Subclasses must implement this method.