001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.http; 014 015import static org.apache.juneau.internal.StringUtils.*; 016 017import java.util.*; 018 019import org.apache.juneau.collections.*; 020 021/** 022 * Represents valid HTTP 1.1 method name static strings per the RFC 2616 spec. 023 * 024 * <ul class='seealso'> 025 * <li class='extlink'>{@doc ExtRFC2616} 026 * </ul> 027 */ 028public class HttpMethod { 029 030 /** {@doc ExtRFC2616.section9#sec9.2 OPTIONS} */ 031 public static final String OPTIONS = "OPTIONS"; 032 033 /** {@doc ExtRFC2616.section9#sec9.3 GET} */ 034 public static final String GET = "GET"; 035 036 /** {@doc ExtRFC2616.section9#sec9.4 HEAD} */ 037 public static final String HEAD = "HEAD"; 038 039 /** {@doc ExtRFC2616.section9#sec9.5 POST} */ 040 public static final String POST = "POST"; 041 042 /** {@doc ExtRFC2616.section9#sec9.6 PUT} */ 043 public static final String PUT = "PUT"; 044 045 /** {@doc ExtRFC2616.section9#sec9.7 DELETE} */ 046 public static final String DELETE = "DELETE"; 047 048 /** {@doc ExtRFC2616.section9#sec9.8 TRACE} */ 049 public static final String TRACE = "TRACE"; 050 051 /** {@doc ExtRFC2616.section9#sec9.9 CONNECT} */ 052 public static final String CONNECT = "CONNECT"; 053 054 /** {@doc https://tools.ietf.org/html/rfc5789 PATCH} */ 055 public static final String PATCH = "PATCH"; 056 057 /** Special case for a REST method that implements a REST-RPC interface. */ 058 public static final String RRPC = "RRPC"; 059 060 /** A non-standard value. */ 061 public static final String OTHER = "OTHER"; 062 063 /** Represents any HTTP method. */ 064 public static final String ANY = "*"; 065 066 private static final Set<String> NO_BODY_METHODS = ASet.unmodifiable("GET","HEAD","DELETE","CONNECT","OPTIONS","TRACE"); 067 068 /** 069 * Returns <jk>true</jk> if specified http method has content. 070 * <p> 071 * By default, anything not in this list can have content: <c>GET, HEAD, DELETE, CONNECT, OPTIONS, TRACE</c>. 072 * 073 * @param name The HTTP method. 074 * @return <jk>true</jk> if specified http method has content. 075 */ 076 public static boolean hasContent(String name) { 077 return ! NO_BODY_METHODS.contains(emptyIfNull(name).toUpperCase()); 078 } 079}