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 org.apache.juneau.http.annotation.*;
016
017/**
018 * Represents a parsed <l>Referer</l> HTTP request header.
019 *
020 * <p>
021 * This is the address of the previous web page from which a link to the currently requested page was followed.
022 * (The word “referrer” has been misspelled in the RFC as well as in most implementations to the point that it has
023 * become standard usage and is considered correct terminology)
024 *
025 * <h5 class='figure'>Example</h5>
026 * <p class='bcode w800'>
027 *    Referer: http://en.wikipedia.org/wiki/Main_Page
028 * </p>
029 *
030 * <h5 class='topic'>RFC2616 Specification</h5>
031 *
032 * The Referer[sic] request-header field allows the client to specify, for the server's benefit, the address (URI) of
033 * the resource from which the Request-URI was obtained (the "referrer", although the header field is misspelled.)
034 * The Referer request-header allows a server to generate lists of back-links to resources for interest, logging,
035 * optimized caching, etc.
036 * It also allows obsolete or mistyped links to be traced for maintenance.
037 * The Referer field MUST NOT be sent if the Request-URI was obtained from a source that does not have its own URI,
038 * such as input from the user keyboard.
039 *
040 * <p class='bcode w800'>
041 *    Referer        = "Referer" ":" ( absoluteURI | relativeURI )
042 * </p>
043 *
044 * <p>
045 * Example:
046 * <p class='bcode w800'>
047 *    Referer: http://www.w3.org/hypertext/DataSources/Overview.html
048 * </p>
049 *
050 * <p>
051 * If the field value is a relative URI, it SHOULD be interpreted relative to the Request-URI.
052 * The URI MUST NOT include a fragment. See section 15.1.3 for security considerations.
053 *
054 * <ul class='seealso'>
055 *    <li class='extlink'>{@doc RFC2616}
056 * </ul>
057 */
058@Header("Referer")
059public final class Referer extends HeaderUri {
060
061   /**
062    * Returns a parsed <c>Referer</c> header.
063    *
064    * @param value The <c>Referer</c> header string.
065    * @return The parsed <c>Referer</c> header, or <jk>null</jk> if the string was null.
066    */
067   public static Referer forString(String value) {
068      if (value == null)
069         return null;
070      return new Referer(value);
071   }
072
073   private Referer(String value) {
074      super(value);
075   }
076}