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>User-Agent</l> HTTP request header.
019 *
020 * <p>
021 * The user agent string of the user agent.
022 *
023 * <h5 class='figure'>Example</h5>
024 * <p class='bcode w800'>
025 *    User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/21.0
026 * </p>
027 *
028 * <h5 class='topic'>RFC2616 Specification</h5>
029 *
030 * The User-Agent request-header field contains information about the user agent originating the request.
031 * This is for statistical purposes, the tracing of protocol violations, and automated recognition of user agents for
032 * the sake of tailoring responses to avoid particular user agent limitations.
033 * User agents SHOULD include this field with requests.
034 * The field can contain multiple product tokens (section 3.8) and comments identifying the agent and any sub-products
035 * which form a significant part of the user agent.
036 * By convention, the product tokens are listed in order of their significance for identifying the application.
037 *
038 * <p class='bcode w800'>
039 *    User-Agent     = "User-Agent" ":" 1*( product | comment )
040 * </p>
041 *
042 * <p>
043 * Example:
044 * <p class='bcode w800'>
045 *    User-Agent: CERN-LineMode/2.15 libwww/2.17b3
046 * </p>
047 *
048 * <h5 class='section'>See Also:</h5>
049 * <ul class='doctree'>
050 *    <li class='extlink'>{@doc RFC2616}
051 * </ul>
052 */
053@Header("User-Agent")
054public final class UserAgent extends HeaderString {
055
056   /**
057    * Returns a parsed <code>User-Agent</code> header.
058    *
059    * @param value The <code>User-Agent</code> header string.
060    * @return The parsed <code>User-Agent</code> header, or <jk>null</jk> if the string was null.
061    */
062   public static UserAgent forString(String value) {
063      if (value == null)
064         return null;
065      return new UserAgent(value);
066   }
067
068   private UserAgent(String value) {
069      super(value);
070   }
071}