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>From</l> HTTP request header.
025 *
026 * <p>
027 * The email address of the user making the request.
028 *
029 * <h5 class='figure'>Example</h5>
030 * <p class='bcode'>
031 *    From: user@example.com
032 * </p>
033 *
034 * <h5 class='topic'>RFC2616 Specification</h5>
035 *
036 * The From request-header field, if given, SHOULD contain an Internet e-mail address for the human user who controls
037 * the requesting user agent.
038 * The address SHOULD be machine-usable, as defined by "mailbox" in RFC 822 [9] as updated by RFC 1123 [8]:
039 *
040 * <p class='bcode'>
041 *    From   = "From" ":" mailbox
042 * </p>
043 *
044 * <p>
045 * An example is:
046 * <p class='bcode'>
047 *    From: webmaster@w3.org
048 * </p>
049 *
050 * <p>
051 * This header field MAY be used for logging purposes and as a means for identifying the source of invalid or unwanted
052 * requests.
053 * It SHOULD NOT be used as an insecure form of access protection.
054 * The interpretation of this field is that the request is being performed on behalf of the person given, who accepts
055 * responsibility for the method performed.
056 * In particular, robot agents SHOULD include this header so that the person responsible for running the robot can be
057 * contacted if problems occur on the receiving end.
058 *
059 * <p>
060 * The Internet e-mail address in this field MAY be separate from the Internet host which issued the request.
061 * For example, when a request is passed through a proxy the original issuer's address SHOULD be used.
062 *
063 * <p>
064 * The client SHOULD NOT send the From header field without the user's approval, as it might conflict with the user's
065 * privacy interests or their site's security policy.
066 * It is strongly recommended that the user be able to disable, enable, and modify the value of this field at any time
067 * prior to a request.
068 *
069 * <h5 class='section'>See Also:</h5><ul>
070 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauRestCommonBasics">juneau-rest-common Basics</a>
071 *    <li class='extlink'><a class="doclink" href="https://www.w3.org/Protocols/rfc2616/rfc2616.html">Hypertext Transfer Protocol -- HTTP/1.1</a>
072 * </ul>
073 *
074 * @serial exclude
075 */
076@Header("From")
077public class From extends BasicStringHeader {
078
079   //-----------------------------------------------------------------------------------------------------------------
080   // Static
081   //-----------------------------------------------------------------------------------------------------------------
082
083   private static final long serialVersionUID = 1L;
084   private static final String NAME = "From";
085
086   /**
087    * Static creator.
088    *
089    * @param value
090    *    The header value.
091    *    <br>Can be <jk>null</jk>.
092    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
093    */
094   public static From of(String value) {
095      return value == null ? null : new From(value);
096   }
097
098   /**
099    * Static creator with delayed value.
100    *
101    * <p>
102    * Header value is re-evaluated on each call to {@link #getValue()}.
103    *
104    * @param value
105    *    The supplier of the header value.
106    *    <br>Can be <jk>null</jk>.
107    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
108    */
109   public static From of(Supplier<String> value) {
110      return value == null ? null : new From(value);
111   }
112
113   //-----------------------------------------------------------------------------------------------------------------
114   // Instance
115   //-----------------------------------------------------------------------------------------------------------------
116
117   /**
118    * Constructor.
119    *
120    * @param value
121    *    The header value.
122    *    <br>Can be <jk>null</jk>.
123    */
124   public From(String value) {
125      super(NAME, value);
126   }
127
128   /**
129    * Constructor with delayed value.
130    *
131    * <p>
132    * Header value is re-evaluated on each call to {@link #getValue()}.
133    *
134    * @param value
135    *    The supplier of the header value.
136    *    <br>Can be <jk>null</jk>.
137    */
138   public From(Supplier<String> value) {
139      super(NAME, value);
140   }
141}