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>Location</l> HTTP response header.
019 *
020 * <p>
021 * Used in redirection, or when a new resource has been created.
022 *
023 * <h5 class='figure'>Example</h5>
024 * <p class='bcode w800'>
025 *    Location: http://www.w3.org/pub/WWW/People.html
026 * </p>
027 *
028 * <h5 class='topic'>RFC2616 Specification</h5>
029 *
030 * The Location response-header field is used to redirect the recipient to a location other than the Request-URI for
031 * completion of the request or identification of a new resource.
032 * For 201 (Created) responses, the Location is that of the new resource which was created by the request.
033 * For 3xx responses, the location SHOULD indicate the server's preferred URI for automatic redirection to the resource.
034 * The field value consists of a single absolute URI.
035 *
036 * <p class='bcode w800'>
037 *    Location       = "Location" ":" absoluteURI
038 * </p>
039 *
040 * <p>
041 * An example is:
042 * <p class='bcode w800'>
043 *    Location: http://www.w3.org/pub/WWW/People.html
044 * </p>
045 *
046 * <p>
047 * Note: The Content-Location header field (section 14.14) differs from Location in that the Content-Location identifies
048 * the original location of the entity enclosed in the request.
049 * It is therefore possible for a response to contain header fields for both Location and Content-Location.
050 * Also see section 13.10 for cache requirements of some methods.
051 *
052 * <h5 class='section'>See Also:</h5>
053 * <ul class='doctree'>
054 *    <li class='extlink'>{@doc RFC2616}
055 * </ul>
056 */
057@Header("Location")
058public final class Location extends HeaderUri {
059
060   /**
061    * Returns a parsed <code>Location</code> header.
062    *
063    * @param value The <code>Location</code> header string.
064    * @return The parsed <code>Location</code> header, or <jk>null</jk> if the string was null.
065    */
066   public static Location forString(String value) {
067      if (value == null)
068         return null;
069      return new Location(value);
070   }
071
072   private Location(String value) {
073      super(value);
074   }
075}