code: @Nullable
      private CorsPolicy setCorsOrigin(ServiceRequestContext ctx, HttpRequest request, HttpHeaders headers) {
          if (!config.isEnabled()) {
              return null;
          }
  
          final String origin = request.headers().get(HttpHeaderNames.ORIGIN);
          if (origin != null) {
              final CorsPolicy policy = config.getPolicy(origin, ctx.pathMappingContext());
              if (policy == null) {
                  logger.debug(
                          "{} There is no CORS policy configured for the request origin '{}' and the path '{}'.",
                          ctx, origin, ctx.path());
                  return null;
              }
              if (NULL_ORIGIN.equals(origin)) {
                  setCorsNullOrigin(headers);
                  return policy;
              }
              if (config.isAnyOriginSupported()) {
                  if (policy.isCredentialsAllowed()) {
                      echoCorsRequestOrigin(request, headers);
                      setCorsVaryHeader(headers);
                  } else {
                      setCorsAnyOrigin(headers);
                  }
                  return policy;
              }
              setCorsOrigin(headers, origin);
              setCorsVaryHeader(headers);
              return policy;
          }
          return null;
      }
docs: Sets origin header according to the given CORS configuration and HTTP request.
  
  @param request the HTTP request
  @param headers the HTTP headers to modify
  
  @return {@code policy} if CORS configuration matches, otherwise {@code null}