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.header; 014 015import java.util.function.*; 016 017import org.apache.juneau.http.annotation.*; 018 019/** 020 * Represents a parsed <l>Server</l> HTTP response header. 021 * 022 * <p> 023 * A name for the server. 024 * 025 * <h5 class='figure'>Example</h5> 026 * <p class='bcode w800'> 027 * Server: Apache/2.4.1 (Unix) 028 * </p> 029 * 030 * <h5 class='topic'>RFC2616 Specification</h5> 031 * 032 * The Server response-header field contains information about the software used by the origin server to handle the 033 * request. 034 * The field can contain multiple product tokens (section 3.8) and comments identifying the server and any significant 035 * sub-products. 036 * The product tokens are listed in order of their significance for identifying the application. 037 * 038 * <p class='bcode w800'> 039 * Server = "Server" ":" 1*( product | comment ) 040 * </p> 041 * 042 * <p> 043 * Example: 044 * <p class='bcode w800'> 045 * Server: CERN/3.0 libwww/2.17 046 * </p> 047 * 048 * <p> 049 * If the response is being forwarded through a proxy, the proxy application MUST NOT modify the Server response-header. 050 * Instead, it SHOULD include a Via field (as described in section 14.45). 051 * 052 * <p> 053 * Note: Revealing the specific software version of the server might allow the server machine to become more vulnerable 054 * to attacks against software that is known to contain security holes. 055 * Server implementors are encouraged to make this field a configurable option. 056 * 057 * <ul class='seealso'> 058 * <li class='extlink'>{@doc ExtRFC2616} 059 * </ul> 060 */ 061@Header("Server") 062public class Server extends BasicStringHeader { 063 064 private static final long serialVersionUID = 1L; 065 066 /** 067 * Convenience creator. 068 * 069 * @param value 070 * The header value. 071 * <br>Can be any of the following: 072 * <ul> 073 * <li>{@link String} 074 * <li>Anything else - Converted to <c>String</c> then parsed. 075 * </ul> 076 * @return A new {@link Server} object. 077 */ 078 public static Server of(Object value) { 079 if (value == null) 080 return null; 081 return new Server(value); 082 } 083 084 /** 085 * Convenience creator using supplier. 086 * 087 * <p> 088 * Header value is re-evaluated on each call to {@link #getValue()}. 089 * 090 * @param value 091 * The header value supplier. 092 * <br>Can be any of the following: 093 * <ul> 094 * <li>{@link String} 095 * <li>Anything else - Converted to <c>String</c> then parsed. 096 * </ul> 097 * @return A new {@link Server} object. 098 */ 099 public static Server of(Supplier<?> value) { 100 if (value == null) 101 return null; 102 return new Server(value); 103 } 104 105 /** 106 * Constructor. 107 * 108 * @param value 109 * The header value. 110 * <br>Can be any of the following: 111 * <ul> 112 * <li>{@link String} 113 * <li>Anything else - Converted to <c>String</c> then parsed. 114 * <li>A {@link Supplier} of anything on this list. 115 * </ul> 116 */ 117 public Server(Object value) { 118 super("Server", value); 119 } 120 121 /** 122 * Constructor 123 * 124 * @param value 125 * The header value. 126 */ 127 public Server(String value) { 128 this((Object)value); 129 } 130}