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   private static final long serialVersionUID = 1L;
079   private static final String NAME = "From";
080
081   /**
082    * Static creator.
083    *
084    * @param value
085    *    The header value.
086    *    <br>Can be <jk>null</jk>.
087    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
088    */
089   public static From of(String value) {
090      return value == null ? null : new From(value);
091   }
092
093   /**
094    * Static creator with delayed value.
095    *
096    * <p>
097    * Header value is re-evaluated on each call to {@link #getValue()}.
098    *
099    * @param value
100    *    The supplier of the header value.
101    *    <br>Can be <jk>null</jk>.
102    * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>.
103    */
104   public static From of(Supplier<String> value) {
105      return value == null ? null : new From(value);
106   }
107
108   /**
109    * Constructor.
110    *
111    * @param value
112    *    The header value.
113    *    <br>Can be <jk>null</jk>.
114    */
115   public From(String value) {
116      super(NAME, value);
117   }
118
119   /**
120    * Constructor with delayed value.
121    *
122    * <p>
123    * Header value is re-evaluated on each call to {@link #getValue()}.
124    *
125    * @param value
126    *    The supplier of the header value.
127    *    <br>Can be <jk>null</jk>.
128    */
129   public From(Supplier<String> value) {
130      super(NAME, value);
131   }
132}