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