<!--
{
  "availability" : [
    "macOS: 10.3.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WebResourceLoadDelegate/webView(_:resource:willSend:redirectResponse:from:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(pl)WebResourceLoadDelegate(im)webView:resource:willSendRequest:redirectResponse:fromDataSource:"
  },
  "title" : "webView(_:resource:willSend:redirectResponse:from:)"
}
-->

# webView(_:resource:willSend:redirectResponse:from:)

Invoked before a request is initiated for a resource and returns a possibly modified request.

```
optional func webView(_ sender: WebView!, resource identifier: Any!, willSend request: URLRequest!, redirectResponse: URLResponse!, from dataSource: WebDataSource!) -> URLRequest!
```

## Parameters

`sender`

The web view that sent this message.

`identifier`

An identifier object used to track the resource being loaded by `dataSource`.

`request`

The request that is sent.

`redirectResponse`

The redirect server response. If `nil`, there is no redirect in progress.

`dataSource`

The data source for this web view.

## Return Value

A possibly modified request.

## Discussion

Delegates might implement this method to modify resource requests before they are sent. Note that this method might be invoked multiple times per load (as a result of a server redirect) where as the  [`webView(_:identifierForInitialRequest:from:)`](/documentation/WebKit/WebResourceLoadDelegate/webView(_:identifierForInitialRequest:from:)) method is invoked once.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)