A mutable URL load request that bridges to NSURLRequest; use NSMutable when you need reference semantics or other Foundation-specific behavior
SDKs
- iOS 2.0+
- macOS 10.2+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Foundation
Declaration
class NSMutableURLRequest : NSURLRequest
Overview
NSMutable is a subclass of NSURLRequest that enables you to mutate a single request object for a series of URL load requests instead of creating an immutable NSURLRequest object for each load.
Important
This class only encapsulates information about a URL request. You must use other classes such as URLSession to send these requests to a server. See Fetching Website Data into Memory and Uploading Data to a Website for an introduction to these techniques.
NSMutable, like NSURLRequest, is designed to be extended to support additional protocols by creating extensions that provide accessor methods for your own protocol-specific properties. Those methods can get and set the actual values by calling the URLProtocol methods property(for and set.
The URLSession, NSURLConnection, and NSURLDownload classes make a deep copy of each NSMutable object passed to their initializers and task creation methods.
Important
The Swift overlay to the Foundation framework provides the URLRequest structure, which bridges to the NSMutable class and its immutable superclass, NSURLRequest. For more information about value types, see Working with Cocoa Frameworks in Using Swift with Cocoa and Objective-C (Swift 4.1).
Reserved HTTP Headers
The URL Loading System is designed to handle various aspects of the HTTP protocol for you. As a result, you should not modify the following headers using the add or set methods:
AuthorizationConnectionHostProxy-AuthenticateProxy-AuthorizationWWW-Authenticate