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>Content-Encoding</l> HTTP response header.
019 *
020 * <p>
021 * The type of encoding used on the data.
022 *
023 * <h5 class='figure'>Example</h5>
024 * <p class='bcode w800'>
025 *    Content-Encoding: gzip
026 * </p>
027 *
028 * <h5 class='topic'>RFC2616 Specification</h5>
029 *
030 * The Content-Encoding entity-header field is used as a modifier to the media-type.
031 * When present, its value indicates what additional content codings have been applied to the entity-body, and thus
032 * what decoding mechanisms must be applied in order to obtain the media-type referenced by the Content-Type header
033 * field.
034 * Content-Encoding is primarily used to allow a document to be compressed without losing the identity of its
035 * underlying media type.
036 * <p class='bcode w800'>
037 *    Content-Encoding  = "Content-Encoding" ":" 1#content-coding
038 * </p>
039 *
040 * <p>
041 * Content codings are defined in section 3.5. An example of its use is...
042 * <p class='bcode w800'>
043 *    Content-Encoding: gzip
044 * </p>
045 *
046 * <p>
047 * The content-coding is a characteristic of the entity identified by the Request-URI.
048 * Typically, the entity-body is stored with this encoding and is only decoded before rendering or analogous usage.
049 * However, a non-transparent proxy MAY modify the content-coding if the new coding is known to be acceptable to the
050 * recipient, unless the "no-transform" cache-control directive is present in the message.
051 *
052 * <p>
053 * If the content-coding of an entity is not "identity", then the response MUST include a Content-Encoding
054 * entity-header (section 14.11) that lists the non-identity content-coding(s) used.
055 *
056 * <p>
057 * If the content-coding of an entity in a request message is not acceptable to the origin server, the server SHOULD
058 * respond with a status code of 415 (Unsupported Media Type).
059 *
060 * <p>
061 * If multiple encodings have been applied to an entity, the content codings MUST be listed in the order in which they
062 * were applied.
063 * Additional information about the encoding parameters MAY be provided.
064 *
065 * <h5 class='section'>See Also:</h5>
066 * <ul class='doctree'>
067 *    <li class='extlink'>{@doc RFC2616}
068 * </ul>
069 */
070@Header(name="Content-Encoding",_enum={"gzip","compress","deflate","identity","other"})
071public final class ContentEncoding extends HeaderEnum<ContentEncodingEnum> {
072
073   /**
074    * Returns a parsed <code>Content-Encoding</code> header.
075    *
076    * @param value The <code>Content-Encoding</code> header string.
077    * @return The parsed <code>Content-Encoding</code> header, or <jk>null</jk> if the string was null.
078    */
079   public static ContentEncoding forString(String value) {
080      if (value == null)
081         return null;
082      return new ContentEncoding(value);
083   }
084
085   private ContentEncoding(String value) {
086      super(value, ContentEncodingEnum.class, ContentEncodingEnum.OTHER);
087   }
088}