HttpRequestMethod.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */

  20. package org.openspcoop2.utils.transport.http;

  21. import java.io.Serializable;

  22. /**
  23.  * HttpRequestMethod
  24.  *
  25.  * @author Poli Andrea (apoli@link.it)
  26.  * @author $Author$
  27.  * @version $Rev$, $Date$
  28.  */
  29. public enum HttpRequestMethod implements Serializable {

  30.     // STANDARD
  31.     GET, HEAD, POST, PUT, DELETE, OPTIONS, TRACE,
  32.    
  33.     // ADDITIONAL
  34.     // Servlet: Method PATCH is not defined in RFC 2068 and is not supported by the Servlet API
  35.     // https://tools.ietf.org/html/rfc2068#section-19.6.1
  36.     PATCH, LINK, UNLINK;
  37.    
  38.     // https://tools.ietf.org/html/rfc2068#section-9
  39.     public boolean isStandardMethod() {
  40.         if(HttpRequestMethod.GET.name().equals(this.name())
  41.                 ||
  42.             HttpRequestMethod.HEAD.name().equals(this.name())
  43.             ||
  44.             HttpRequestMethod.POST.name().equals(this.name())
  45.             ||
  46.             HttpRequestMethod.PUT.name().equals(this.name())
  47.             ||
  48.             HttpRequestMethod.DELETE.name().equals(this.name())
  49.             ||
  50.             HttpRequestMethod.OPTIONS.name().equals(this.name())
  51.             ||
  52.             HttpRequestMethod.TRACE.name().equals(this.name())
  53.                 ){
  54.             return true;
  55.         }
  56.         return false;
  57.     }
  58.    
  59.     // https://tools.ietf.org/html/rfc2068#section-19.6.1
  60.     public boolean isAdditionalMethod() {
  61.         if(HttpRequestMethod.PATCH.name().equals(this.name())
  62.                 ||
  63.             HttpRequestMethod.LINK.name().equals(this.name())
  64.             ||
  65.             HttpRequestMethod.UNLINK.name().equals(this.name())
  66.                 ){
  67.             return true;
  68.         }
  69.         return false;
  70.     }
  71.    
  72.     public boolean equals(String object){
  73.         if(object==null)
  74.             return false;
  75.         return object.equals(this.name());  
  76.     }
  77. }