Class: NSURLRequest

Inherits:
NSObject show all

Overview

NSURLRequest objects represent a URL load request in a manner independent of protocol and URL scheme.

Direct Known Subclasses

NSMutableURLRequest

Class Method Summary (collapse)

Instance Method Summary (collapse)

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

+ (Object) requestWithURL(theURL)

Creates and returns a URL request for a specified URL with default cache policy and timeout value. The default cache policy is NSURLRequestUseProtocolCachePolicy and the default timeout interval is 60 seconds.

Parameters:

  • theURL (NSURL)

    The URL for the new request.

Returns:

  • (Object)

    The newly created URL request.

+ (Object) requestWithURL(theURL, cachePolicy:cachePolicy, timeoutInterval:timeoutInterval)

Creates and returns an initialized URL request with specified values.

Parameters:

  • theURL (NSURL)

    The URL for the new request.

  • cachePolicy (NSURLRequestCachePolicy)

    The cache policy for the new request.

  • timeoutInterval (NSTimeInterval)

    The timeout interval for the new request, in seconds.

Returns:

  • (Object)

    The newly created URL request.

Instance Method Details

- (Hash) allHTTPHeaderFields

Returns a dictionary containing all the receiver’s HTTP header fields.

Returns:

  • (Hash)

    A dictionary containing all the receiver’s HTTP header fields.

- (Boolean) allowsCellularAccess

Returns whether the request is allowed to use the cellular radio (if present).

Returns:

  • (Boolean)

    YES if the cellular radio can be used; NO otherwise.

- (NSURLRequestCachePolicy) cachePolicy

Returns the receiver’s cache policy.

Returns:

  • (NSURLRequestCachePolicy)

    The receiver’s cache policy.

- (NSData) HTTPBody

Returns the receiver’s HTTP body data. This data is sent as the message body of a request, as in an HTTP POST request.

Returns:

  • (NSData)

    The receiver’s HTTP body data.

- (NSInputStream) HTTPBodyStream

Returns the receiver’s HTTP body stream. The receiver will have either an HTTP body or an HTTP body stream, only one may be set for a request. A HTTP body stream is preserved when copying an NSURLRequest object, but is lost when a request is archived using the NSCoding protocol.

Returns:

  • (NSInputStream)

    The receiver’s HTTP body stream, or nil if it has not been set. The returned stream is for examination only, it is not safe to manipulate the stream in any way.

- (String) HTTPMethod

Returns the receiver’s HTTP request method. The default HTTP method is “GET”.

Returns:

  • (String)

    The receiver’s HTTP request method.

- (Boolean) HTTPShouldHandleCookies

Returns whether the default cookie handling will be used for this request. The default is YES.

Returns:

  • (Boolean)

    YES if the default cookie handling will be used for this request, NO otherwise.

- (Boolean) HTTPShouldUsePipelining

Returns whether the request should continue transmitting data before receiving a response from an earlier transmission.

Returns:

  • (Boolean)

    YES if the request should continue transmitting data; otherwise, NO.

- (Object) initWithURL(theURL)

Returns a URL request for a specified URL with default cache policy and timeout value. The default cache policy is NSURLRequestUseProtocolCachePolicy and the default timeout interval is 60 seconds.

Parameters:

  • theURL (NSURL)

    The URL for the request.

Returns:

  • (Object)

    The initialized URL request.

- (Object) initWithURL(theURL, cachePolicy:cachePolicy, timeoutInterval:timeoutInterval)

Returns an initialized URL request with specified values. This is the designated initializer for NSURLRequest.

Parameters:

  • theURL (NSURL)

    The URL for the request.

  • cachePolicy (NSURLRequestCachePolicy)

    The cache policy for the request.

  • timeoutInterval (NSTimeInterval)

    The timeout interval for the request, in seconds.

Returns:

  • (Object)

    The initialized URL request.

- (NSURL) mainDocumentURL

Returns the main document URL associated with the request. This URL is used for the cookie “same domain as main document” policy.

Returns:

  • (NSURL)

    The main document URL associated with the request.

- (NSURLRequestNetworkServiceType) networkServiceType

Returns the network service type of the request.

Returns:

  • (NSURLRequestNetworkServiceType)

    The network service type of the request.

- (NSTimeInterval) timeoutInterval

Returns the receiver’s timeout interval, in seconds. If during a connection attempt the request remains idle for longer than the timeout interval, the request is considered to have timed out.

Returns:

  • (NSTimeInterval)

    The receiver’s timeout interval, in seconds.

- (NSURL) URL

Returns the request's URL.

Returns:

  • (NSURL)

    The request's URL.

- (String) valueForHTTPHeaderField(field)

Returns the value of the specified HTTP header field.

Parameters:

  • field (String)

    The name of the header field whose value is to be returned. In keeping with the HTTP RFC, HTTP header field names are case-insensitive.

Returns:

  • (String)

    The value associated with the header field field, or nil if there is no corresponding header field.