applyCORSHeadersIfNecessary method Null safety

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

Implementation

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