Contents

URLRequest

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

Declaration

struct URLRequest

Mentioned in

Overview

URLRequest encapsulates two essential properties of a load request: the URL to load and the policies used to load it. In addition, for HTTP and HTTPS requests, URLRequest includes the HTTP method (GET, POST, and so on) and the HTTP headers.

URLRequest 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.

When writing Swift code, favor this structure over the NSURLRequest and NSMutableURLRequest classes.

Certain header fields are reserved; see Reserved HTTP headers.

Topics

Creating a request

Working with a cache policy

Accessing request components

Accessing header fields

Controlling request behavior

Supporting limited modes

Accessing the service type

Indicating the source of the request

Using reference types

Instance Properties

See Also

Requests and responses