<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.2.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSURLConnection/canHandle(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSURLConnection(cm)canHandleRequest:"
  },
  "title" : "canHandle(_:)"
}
-->

# canHandle(_:)

Returns whether a request can be handled based on a preflight evaluation.

```
class func canHandle(_ request: URLRequest) -> Bool
```

## Parameters

`request`

The request to evaluate. The connection deep-copies the request on creation.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if a preflight operation determines that a connection with `request` can be created and the associated I/O can be started, <doc://com.apple.documentation/documentation/Swift/false> otherwise.

## Discussion

The result of this method is valid as long as no [`URLProtocol`](/documentation/Foundation/URLProtocol) classes are registered or unregistered, and `request` remains unchanged. Applications should be prepared to handle failures even if they have performed request preflighting by calling this method.

## See Also

[`unregisterClass(_:)`](/documentation/Foundation/URLProtocol/unregisterClass(_:))

Unregisters the specified subclass of [`URLProtocol`](/documentation/Foundation/URLProtocol).

[`registerClass(_:)`](/documentation/Foundation/URLProtocol/registerClass(_:))

Attempts to register a subclass of [`URLProtocol`](/documentation/Foundation/URLProtocol), making it visible to the URL loading system.

[URL Loading System](/documentation/Foundation/url-loading-system)

Interact with URLs and communicate with servers using standard Internet protocols.



---

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)