<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WKURLSchemeTask/didReceive(_:)-2u23r",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(pl)WKURLSchemeTask(im)didReceiveResponse:"
  },
  "title" : "didReceive(_:)"
}
-->

# didReceive(_:)

Returns a URL response to WebKit with information about the requested resource.

```
func didReceive(_ response: URLResponse)
```

## Parameters

`response`

The response to return to WebKit. Your response object must include the MIME type of the requested resource.

## Discussion

Call this method to provide WebKit with the MIME type of the requested resource and its expected size. You must call this method at least once for each task, and you may call it multiple times if needed. Always call it before sending any data back to WebKit using the [`didReceive(_:)`](/documentation/WebKit/WKURLSchemeTask/didReceive(_:)-8t5f8) method.

It is a programmer error to call this method after calling the [`didFinish()`](/documentation/WebKit/WKURLSchemeTask/didFinish()) method of the same task object. It is also a programmer error to call this method after WebKit calls the [`webView(_:stop:)`](/documentation/WebKit/WKURLSchemeHandler/webView(_:stop:)) method of the corresponding handler object. If you do, this method raises an exception in both cases.

---

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)