Up

# NSURLRequest documentation

### Authors

Richard Frith-Macdonald (`frm@gnu.org`)

Date: Generated at 2025-02-13 06:02:40 +0000

Copyright: (C) 2006 Software Foundation, Inc.

### Contents -

1. Software documentation for the NSMutableURLRequest class
2. Software documentation for the NSURLRequest class
3. Software documentation for the NSMutableURLRequest(GNUstep) category
4. Software documentation for the NSMutableURLRequest(NSMutableHTTPURLRequest) category
5. Software documentation for the NSURLRequest(NSHTTPURLRequest) category

# Software documentation for the NSMutableURLRequest class

## NSMutableURLRequest : NSURLRequest

> Declared in:
>   Foundation/NSURLRequest.h

Availability: MacOS-X 10.2.0, Base 1.13.0
Description forthcoming.
Method summary

- -setDebug:
- -setDebugLogDelegate:
- -addValue:forHTTPHeaderField:
- -setAllHTTPHeaderFields:
- -setHTTPBody:
- -setHTTPBodyStream:
- -setHTTPMethod:
- -setHTTPShouldHandleCookies:
- -setValue:forHTTPHeaderField:
- -setCachePolicy:
- -setMainDocumentURL:
- -setTimeoutInterval:
- -setURL:

### setCachePolicy:

- (void) setCachePolicy: (NSURLRequestCachePolicy)cachePolicy;
Availability: MacOS-X 10.2.0, Base 1.13.0
Sets the receiver's cache policy.

### setMainDocumentURL:

- (void) setMainDocumentURL: (NSURL*)URL;
Availability: MacOS-X 10.2.0, Base 1.13.0
Sets the receiver's main document.

### setTimeoutInterval:

- (void) setTimeoutInterval: (NSTimeInterval)seconds;
Availability: MacOS-X 10.2.0, Base 1.13.0
Sets the receiver's timeout policy.

### setURL:

- (void) setURL: (NSURL*)URL;
Availability: MacOS-X 10.2.0, Base 1.13.0
Sets the receiver's URL

# Software documentation for the NSURLRequest class

## NSURLRequest : NSObject

> Declared in:
>   Foundation/NSURLRequest.h

> Conforms to:
>   NSCoding
>   NSCopying
>   NSMutableCopying

Availability: MacOS-X 10.2.0, Base 1.13.0
This class encapsulates information about a request to load a URL, how to cache the results, and when to deal with a slow/hung load process by timing out.

Instance Variables
Method summary

- -HTTPBody
- -HTTPBodyStream
- -HTTPMethod
- -HTTPShouldHandleCookies
- -allHTTPHeaderFields
- -valueForHTTPHeaderField:
- +requestWithURL:
- +requestWithURL:cachePolicy:timeoutInterval:
- -URL
- -cachePolicy
- -initWithURL:
- -initWithURL:cachePolicy:timeoutInterval:
- -mainDocumentURL
- -timeoutInterval

### requestWithURL:

+ (instancetype) requestWithURL: (NSURL*)URL;
Availability: MacOS-X 10.2.0, Base 1.13.0
Description forthcoming.

### requestWithURL: cachePolicy: timeoutInterval:

+ (instancetype) requestWithURL: (NSURL*)URL cachePolicy: (NSURLRequestCachePolicy)cachePolicy timeoutInterval: (NSTimeInterval)timeoutInterval;
Availability: MacOS-X 10.2.0, Base 1.13.0
Returns an autoreleased instance initialised with the specified URL, cachePolicy, and timeoutInterval.

### URL

- (NSURL*) URL;
Availability: MacOS-X 10.2.0, Base 1.13.0
Returns the URL associated with the receiver.

### cachePolicy

- (NSURLRequestCachePolicy) cachePolicy;
Availability: MacOS-X 10.2.0, Base 1.13.0
Returns the cache policy associated with the receiver.

### initWithURL:

- (instancetype) initWithURL: (NSURL*)URL;
Availability: MacOS-X 10.2.0, Base 1.13.0
Initialises the reveiver with the specified URL and with the default cache policy (NSURLRequestUseProtocolCachePolicy) and a sixty second timeout.

### initWithURL: cachePolicy: timeoutInterval:

- (instancetype) initWithURL: (NSURL*)URL cachePolicy: (NSURLRequestCachePolicy)cachePolicy timeoutInterval: (NSTimeInterval)timeoutInterval;
Availability: MacOS-X 10.2.0, Base 1.13.0
Initialises the receiver with the specified URL, cachePolicy, and timeoutInterval.

### mainDocumentURL

- (NSURL*) mainDocumentURL;
Availability: MacOS-X 10.2.0, Base 1.13.0
Returns the main document URL for the receiver.
Currently unused.
This is intended for use with frames and similar situations where a main document has a large number of subsidiary documents.

### timeoutInterval

- (NSTimeInterval) timeoutInterval;
Availability: MacOS-X 10.2.0, Base 1.13.0
Returns the timeout interval associated with the receiver.
This is a value in seconds specifying how long the load process may be inactive (waiting for data to arrive from the server) before the load is mconsidered to have failed due to a timeout.

## Instance Variables for NSURLRequest Class

### _NSURLRequestInternal

@protected void* _NSURLRequestInternal;
Availability: MacOS-X 10.2.0, Base 1.13.0
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

# Software documentation for the NSMutableURLRequest(GNUstep) category

## NSMutableURLRequest(GNUstep)

> Declared in:
>   Foundation/NSURLRequest.h

Availability: MacOS-X 10.2.0, Base 1.13.0
Description forthcoming.
Method summary

- -setDebug:
- -setDebugLogDelegate:

### setDebug:

- (int) setDebug: (int)d;
Availability: MacOS-X 10.2.0, Base 1.13.0
Sets a flag to turn on low level debug logging for this request and the corresponding response. The previous vaue of the setting is returned.

### setDebugLogDelegate:

- (id<GSLogDelegate>) setDebugLogDelegate: (id<GSLogDelegate>)d;
Availability: MacOS-X 10.2.0, Base 1.13.0
Sets a delegate object to override logging of low level I/O of the request as it is sent and the corresponding response as it arrives.
The delegate object is not retained, so it is the responsibility of the caller to ensure that it persists until all I/O has completed.
This has no effect unless debug is turned on, but if debug is turned on it permits the delegate to override the default behavior of writing the data to stderr.

# Software documentation for the NSMutableURLRequest(NSMutableHTTPURLRequest) category

## NSMutableURLRequest(NSMutableHTTPURLRequest)

> Declared in:
>   Foundation/NSURLRequest.h

Availability: MacOS-X 10.2.0, Base 1.13.0
Description forthcoming.
Method summary

- -addValue:forHTTPHeaderField:
- -setAllHTTPHeaderFields:
- -setHTTPBody:
- -setHTTPBodyStream:
- -setHTTPMethod:
- -setHTTPShouldHandleCookies:
- -setValue:forHTTPHeaderField:

### addValue: forHTTPHeaderField:

- (void) addValue: (NSString*)value forHTTPHeaderField: (NSString*)field;
Availability: MacOS-X 10.2.0, Base 1.13.0
Appends the value to the specified header field, automatically inserting a comman field delimiter if necessary.

### setAllHTTPHeaderFields:

- (void) setAllHTTPHeaderFields: (NSDictionary*)headerFields;
Availability: MacOS-X 10.2.0, Base 1.13.0
Sets all the string values in the supplied headerFields dictionary as header values in the receiver.
Non-string values are ignored.

### setHTTPBody:

- (void) setHTTPBody: (NSData*)data;
Availability: MacOS-X 10.2.0, Base 1.13.0
Sets the data to be sent as the body of the HTTP request.
Clears any value previously set by -setHTTPBodyStream: or -setHTTPBody:

### setHTTPBodyStream:

- (void) setHTTPBodyStream: (NSInputStream*)inputStream;
Availability: MacOS-X 10.4.0, Base 1.13.0
Sets the request body to be the contents of the given stream.
The stream should be unopened when it is set, and the load process for the request will open the stream and read its entire content forwarding it to the remote server.
Clears any value previously set by -setHTTPBody: or -setHTTPBodyStream:

### setHTTPMethod:

- (void) setHTTPMethod: (NSString*)method;
Availability: MacOS-X 10.2.0, Base 1.13.0
Sets the method of the receiver.

### setHTTPShouldHandleCookies:

- (void) setHTTPShouldHandleCookies: (BOOL)should;
Availability: MacOS-X 10.2.0, Base 1.13.0
Sets a flag to say whether cookies should automatically be added to the request and whether cookies in the response should be used.

### setValue: forHTTPHeaderField:

- (void) setValue: (NSString*)value forHTTPHeaderField: (NSString*)field;
Availability: MacOS-X 10.2.0, Base 1.13.0
Sets the value for the specified header field, replacing any previously set value. Setting a `nil` value deletes a previously set header field.

# Software documentation for the NSURLRequest(NSHTTPURLRequest) category

## NSURLRequest(NSHTTPURLRequest)

> Declared in:
>   Foundation/NSURLRequest.h

Availability: MacOS-X 10.2.0, Base 1.13.0
HTTP specific additions to NSURLRequest
Method summary

- -HTTPBody
- -HTTPBodyStream
- -HTTPMethod
- -HTTPShouldHandleCookies
- -allHTTPHeaderFields
- -valueForHTTPHeaderField:

### HTTPBody

- (NSData*) HTTPBody;
Availability: MacOS-X 10.2.0, Base 1.13.0
Returns the body of the reques... this is the data sent in a POST request.

### HTTPBodyStream

- (NSInputStream*) HTTPBodyStream;
Availability: MacOS-X 10.4.0, Base 1.13.0
Returns the currently set stream (if any) to be used to provide data to send as the request body.
Of course, any attempt to modify this stream may mess up the load operation in progress.

### HTTPMethod

- (NSString*) HTTPMethod;
Availability: MacOS-X 10.2.0, Base 1.13.0
Returns the HTTP method assiciated with the receiver.

### HTTPShouldHandleCookies

- (BOOL) HTTPShouldHandleCookies;
Availability: MacOS-X 10.2.0, Base 1.13.0
Returns a flag indicating whether this request should use standard cookie handling (sending of cookies with the request and storing any cookies returned in the response.

### allHTTPHeaderFields

- (NSDictionary*) allHTTPHeaderFields;
Availability: MacOS-X 10.2.0, Base 1.13.0
Returns a dictionary of the HTTP header fields associated with the receiver.

### valueForHTTPHeaderField:

- (NSString*) valueForHTTPHeaderField: (NSString*)field;
Availability: MacOS-X 10.2.0, Base 1.13.0
Returns the value for a particular HTTP header field (by case insensitive comparison) or `nil` if no such header is set.

Up