---
title: NSMutableURLRequest
framework: foundation
role: symbol
role_heading: Class
path: foundation/nsmutableurlrequest
---

# NSMutableURLRequest

A mutable URL load request that is independent of protocol or URL scheme.

## Declaration

```swift
class NSMutableURLRequest
```

## Overview

Overview In Swift, this object bridges to NSURLRequest and you use when you need reference semantics or other Foundation-specific behavior. NSMutableURLRequest is a subclass of NSURLRequest that allows you to change the request’s properties. NSMutableURLRequest only represents information about the request. Use other classes, such as URLSession, to send the request to a server. See Fetching website data into memory and Uploading data to a website for an introduction to these techniques. Classes that create a network operation based on a request make a deep copy of that request. Thus, changing the request after creating a network operation has no effect on the ongoing operation. For example, if you use dataTask(with:completionHandler:) to create a data task from a request, and then later change the request, the data task continues using the original request. important: The Swift overlay to the Foundation framework provides the URLRequest structure, which bridges to the NSMutableURLRequest class and its immutable superclass, NSURLRequest. For more information about value types, see Working with Foundation Types.

## Topics

### Working with a cache policy

- [cachePolicy](foundation/nsmutableurlrequest/cachepolicy.md)
- [NSURLRequest.CachePolicy](foundation/nsurlrequest/cachepolicy-swift.enum.md)

### Accessing request components

- [httpMethod](foundation/nsmutableurlrequest/httpmethod.md)
- [url](foundation/nsmutableurlrequest/url.md)
- [httpBody](foundation/nsmutableurlrequest/httpbody.md)
- [httpBodyStream](foundation/nsmutableurlrequest/httpbodystream.md)
- [mainDocumentURL](foundation/nsmutableurlrequest/maindocumenturl.md)

### Accessing header fields

- [allHTTPHeaderFields](foundation/nsmutableurlrequest/allhttpheaderfields.md)
- [addValue(_:forHTTPHeaderField:)](foundation/nsmutableurlrequest/addvalue(_:forhttpheaderfield:).md)
- [setValue(_:forHTTPHeaderField:)](foundation/nsmutableurlrequest/setvalue(_:forhttpheaderfield:).md)

### Controlling request behavior

- [timeoutInterval](foundation/nsmutableurlrequest/timeoutinterval.md)
- [httpShouldHandleCookies](foundation/nsmutableurlrequest/httpshouldhandlecookies.md)
- [httpShouldUsePipelining](foundation/nsmutableurlrequest/httpshouldusepipelining.md)
- [allowsCellularAccess](foundation/nsmutableurlrequest/allowscellularaccess.md)

### Supporting limited modes

- [allowsConstrainedNetworkAccess](foundation/nsmutableurlrequest/allowsconstrainednetworkaccess.md)
- [allowsExpensiveNetworkAccess](foundation/nsmutableurlrequest/allowsexpensivenetworkaccess.md)

### Accessing the service type

- [networkServiceType](foundation/nsmutableurlrequest/networkservicetype.md)
- [NSURLRequest.NetworkServiceType](foundation/nsurlrequest/networkservicetype-swift.enum.md)

### Working with hotspots

- [bind(to:)](foundation/nsmutableurlrequest/bind(to:).md)

### Indicating the source of the request

- [attribution](foundation/nsmutableurlrequest/attribution.md)
- [NSURLRequest.Attribution](foundation/nsurlrequest/attribution-swift.enum.md)

### Instance Properties

- [allowsPersistentDNS](foundation/nsmutableurlrequest/allowspersistentdns.md)
- [allowsUltraConstrainedNetworkAccess](foundation/nsmutableurlrequest/allowsultraconstrainednetworkaccess.md)
- [assumesHTTP3Capable](foundation/nsmutableurlrequest/assumeshttp3capable.md)
- [cookiePartitionIdentifier](foundation/nsmutableurlrequest/cookiepartitionidentifier.md)
- [requiresDNSSECValidation](foundation/nsmutableurlrequest/requiresdnssecvalidation.md)

## Relationships

### Inherits From

- [NSURLRequest](foundation/nsurlrequest.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSMutableCopying](foundation/nsmutablecopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Requests and responses

- [URLRequest](foundation/urlrequest.md)
- [NSURLRequest](foundation/nsurlrequest.md)
- [URLResponse](foundation/urlresponse.md)
- [HTTPURLResponse](foundation/httpurlresponse.md)
