Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/Foundation.framework |
Availability | Available in Mac OS X v10.2 with Safari 1.0 installed. Available in Mac OS X v10.2.7 and later. |
Companion guide | |
Declared in | NSURLRequest.h |
NSMutableURLRequest is a subclass of NSURLRequest provided to aid developers who may find it more convenient to mutate a single request object for a series of URL load requests instead of creating an immutable NSURLRequest for each load.
This programming model is supported by the following contract between NSMutableURLRequest and NSURLConnection: NSURLConnection makes a deep copy of each NSMutableURLRequest object passed to one of its initializers.
NSMutableURLRequest, like NSURLRequest, is designed to be extended to support additional protocols by adding categories that access protocol specific values from a property object using NSURLProtocol’s propertyForKey:inRequest:
and setProperty:forKey:inRequest:
methods.
Adds an HTTP header to the receiver’s HTTP header dictionary.
- (void)addValue:(NSString *)value forHTTPHeaderField:(NSString *)field
The value for the header field.
The name of the header field. In keeping with the HTTP RFC, HTTP header field names are case-insensitive
This method provides the ability to add values to header fields incrementally. If a value was previously set for the specified field, the supplied value is appended to the existing value using the appropriate field delimiter. In the case of HTTP, this is a comma.
NSURLRequest.h
Replaces the receiver's header fields with the passed values.
- (void)setAllHTTPHeaderFields:(NSDictionary *)headerFields
A dictionary with the new header fields. HTTP header fields must be string values; therefore, each object and key in the headerFields dictionary must be a subclass of NSString. If either the key or value for a key-value pair is not a subclass of NSString, the key-value pair is skipped.
NSURLRequest.h
Sets the cache policy of the receiver.
- (void)setCachePolicy:(NSURLRequestCachePolicy)policy
The new cache policy.
NSURLRequest.h
Sets the request body of the receiver to the specified data.
- (void)setHTTPBody:(NSData *)data
The new request body for the receiver. This is sent as the message body of the request, as in an HTTP POST
request.
Setting the HTTP body data clears any input stream set by setHTTPBodyStream:
. These values are mutually exclusive.
NSURLRequest.h
Sets the request body of the receiver to the contents of a specified input stream.
- (void)setHTTPBodyStream:(NSInputStream *)inputStream
The input stream that will be the request body of the receiver. The entire contents of the stream will be sent as the body, as in an HTTP POST
request. The inputStream should be unopened and the receiver will take over as the stream’s delegate.
Setting a body stream clears any data set by setHTTPBody:
. These values are mutually exclusive.
NSURLRequest.h
Sets the receiver’s HTTP request method.
- (void)setHTTPMethod:(NSString *)method
The new HTTP request method. The default HTTP method is “GET”.
NSURLRequest.h
Sets whether the receiver should use the default cookie handling for the request.
- (void)setHTTPShouldHandleCookies:(BOOL)handleCookies
YES
if the receiver should use the default cookie handling for the request, NO
otherwise. The default is YES
.
In Mac OS X v10.2 with Safari 1.0 the value set by this method is not respected by the framework.
NSURLRequest.h
Sets the main document URL for the receiver.
- (void)setMainDocumentURL:(NSURL *)theURL
The new main document URL. Can be nil
.
The caller should set the main document URL to an appropriate main document, if known. For example, when loading a web page the URL of the HTML document for the top-level frame would be appropriate. This URL will be used for the “only from same domain as main document” cookie accept policy.
NSURLRequest.h
Sets the receiver’s timeout interval, in seconds.
- (void)setTimeoutInterval:(NSTimeInterval)timeoutInterval
The 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. The default timeout interval is 60 seconds.
NSURLRequest.h
Sets the URL of the receiver
- (void)setURL:(NSURL *)theURL
The new URL.
NSURLRequest.h
Sets the specified HTTP header field.
- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field
The new value for the header field. Any existing value for the field is replaced by the new value.
The name of the header field to set. In keeping with the HTTP RFC, HTTP header field names are case-insensitive.
NSURLRequest.h
Last updated: 2006-05-23