001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.http.header;
018
019import java.util.function.*;
020
021import org.apache.juneau.http.annotation.*;
022
023/**
024 * Represents a parsed <l>Server</l> HTTP response header.
025 *
026 * <p>
027 * A name for the server.
028 *
029 * <h5 class='figure'>Example</h5>
030 * <p class='bcode'>
031 *    Server: Apache/2.4.1 (Unix)
032 * </p>
033 *
034 * <h5 class='topic'>RFC2616 Specification</h5>
035 *
036 * The Server response-header field contains information about the software used by the origin server to handle the
037 * request.
038 * The field can contain multiple product tokens (section 3.8) and comments identifying the server and any significant
039 * sub-products.
040 * The product tokens are listed in order of their significance for identifying the application.
041 *
042 * <p class='bcode'>
043 *    Server         = "Server" ":" 1*( product | comment )
044 * </p>
045 *
046 * <p>
047 * Example:
048 * <p class='bcode'>
049 *    Server: CERN/3.0 libwww/2.17
050 * </p>
051 *
052 * <p>
053 * If the response is being forwarded through a proxy, the proxy application MUST NOT modify the Server response-header.
054 * Instead, it SHOULD include a Via field (as described in section 14.45).
055 *
056 * <p>
057 * Note: Revealing the specific software version of the server might allow the server machine to become more vulnerable
058 * to attacks against software that is known to contain security holes.
059 * Server implementors are encouraged to make this field a configurable option.
060 *
061 * <h5 class='section'>See Also:</h5><ul>
062 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauRestCommonBasics">juneau-rest-common Basics</a>
063 *    <li class='extlink'><a class="doclink" href="https://www.w3.org/Protocols/rfc2616/rfc2616.html">Hypertext Transfer Protocol -- HTTP/1.1</a>
064 * </ul>
065 *
066 * @serial exclude
067 */
068@Header("Server")
069public class Server extends BasicStringHeader {
070
071   //-----------------------------------------------------------------------------------------------------------------
072   // Static
073   //-----------------------------------------------------------------------------------------------------------------
074
075   private static final long serialVersionUID = 1L;
076   private static final String NAME = "Server";
077
078   /**
079    * Static creator.
080    *
081    * @param value
082    *    The header value.
083    *    <br>Can be <jk>null</jk>.
084    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
085    */
086   public static Server of(String value) {
087      return value == null ? null : new Server(value);
088   }
089
090   /**
091    * Static creator with delayed value.
092    *
093    * <p>
094    * Header value is re-evaluated on each call to {@link #getValue()}.
095    *
096    * @param value
097    *    The supplier of the header value.
098    *    <br>Can be <jk>null</jk>.
099    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
100    */
101   public static Server of(Supplier<String> value) {
102      return value == null ? null : new Server(value);
103   }
104
105   //-----------------------------------------------------------------------------------------------------------------
106   // Instance
107   //-----------------------------------------------------------------------------------------------------------------
108
109   /**
110    * Constructor.
111    *
112    * @param value
113    *    The header value.
114    *    <br>Can be <jk>null</jk>.
115    */
116   public Server(String value) {
117      super(NAME, value);
118   }
119
120   /**
121    * Constructor with delayed value.
122    *
123    * <p>
124    * Header value is re-evaluated on each call to {@link #getValue()}.
125    *
126    * @param value
127    *    The supplier of the header value.
128    *    <br>Can be <jk>null</jk>.
129    */
130   public Server(Supplier<String> value) {
131      super(NAME, value);
132   }
133}