Class CorsResponder

java.lang.Object
com.google.gerrit.httpd.restapi.CorsResponder

public class CorsResponder extends Object
Provides methods for processing CORS requests.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CorsResponder(Pattern allowOrigin)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    checkCors(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, boolean isXd)
    Processes CORS request and add required headers to the response.
    boolean
    filterCorsPreflight(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
    Responses to a CORS preflight request.
    static Pattern
    makeAllowOrigin(org.eclipse.jgit.lib.Config cfg)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CorsResponder

      public CorsResponder(Pattern allowOrigin)
  • Method Details

    • makeAllowOrigin

      public static Pattern makeAllowOrigin(org.eclipse.jgit.lib.Config cfg)
    • filterCorsPreflight

      public boolean filterCorsPreflight(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws BadRequestException
      Responses to a CORS preflight request.

      If the request is a CORS preflight request, the method writes a correct preflight response and returns true. A further processing of the request is not required. Otherwise, the method returns false without adding anything to the response.

      Throws:
      BadRequestException
    • checkCors

      public void checkCors(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, boolean isXd) throws BadRequestException
      Processes CORS request and add required headers to the response.

      The method checks if the incoming request is a CORS request and if so validates the request's origin.

      Throws:
      BadRequestException