applyCORSHeadersIfNecessary method Null safety

void applyCORSHeadersIfNecessary(
  1. Request req,
  2. Response resp
)

Implementation

void applyCORSHeadersIfNecessary(Request req, Response resp) {
  if (req.isCORSRequest && !req.isPreflightRequest) {
    final lastPolicyController = _lastController;
    final p = lastPolicyController.policy;
    if (p != null) {
      if (p.isRequestOriginAllowed(req.raw)) {
        resp.headers.addAll(p.headersForRequest(req));
      }
    }
  }
}