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.header; 014 015import java.util.function.*; 016 017import org.apache.juneau.http.annotation.*; 018 019/** 020 * Represents a parsed <l>Transfer-Encoding</l> HTTP response header. 021 * 022 * <p> 023 * The form of encoding used to safely transfer the entity to the user. 024 * Currently defined methods are: chunked, compress, deflate, gzip, identity. 025 * 026 * <h5 class='figure'>Example</h5> 027 * <p class='bcode'> 028 * Transfer-Encoding: chunked 029 * </p> 030 * 031 * <h5 class='topic'>RFC2616 Specification</h5> 032 * 033 * The Transfer-Encoding general-header field indicates what (if any) type of transformation has been applied to the 034 * message body in order to safely transfer it between the sender and the recipient. 035 * This differs from the content-coding in that the transfer-coding is a property of the message, not of the entity. 036 * 037 * <p class='bcode'> 038 * Transfer-Encoding = "Transfer-Encoding" ":" 1#transfer-coding 039 * </p> 040 * 041 * <p> 042 * Transfer-codings are defined in section 3.6. An example is: 043 * 044 * <p class='bcode'> 045 * Transfer-Encoding: chunked 046 * </p> 047 * 048 * <p> 049 * If multiple encodings have been applied to an entity, the transfer-codings MUST be listed in the order in which 050 * they were applied. 051 * Additional information about the encoding parameters MAY be provided by other entity-header fields not defined by 052 * this specification. 053 * 054 * <p> 055 * Many older HTTP/1.0 applications do not understand the Transfer-Encoding header. 056 * 057 * <h5 class='section'>See Also:</h5><ul> 058 * <li class='link'><a class="doclink" href="../../../../../index.html#juneau-rest-common">juneau-rest-common</a> 059 * <li class='extlink'><a class="doclink" href="https://www.w3.org/Protocols/rfc2616/rfc2616.html">Hypertext Transfer Protocol -- HTTP/1.1</a> 060 * </ul> 061 * 062 * @serial exclude 063 */ 064@Header("Transfer-Encoding") 065public class TransferEncoding extends BasicStringHeader { 066 067 //----------------------------------------------------------------------------------------------------------------- 068 // Static 069 //----------------------------------------------------------------------------------------------------------------- 070 071 private static final long serialVersionUID = 1L; 072 private static final String NAME = "Transfer-Encoding"; 073 074 /** 075 * Static creator. 076 * 077 * @param value 078 * The header value. 079 * <br>Can be <jk>null</jk>. 080 * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>. 081 */ 082 public static TransferEncoding of(String value) { 083 return value == null ? null : new TransferEncoding(value); 084 } 085 086 /** 087 * Static creator with delayed value. 088 * 089 * <p> 090 * Header value is re-evaluated on each call to {@link #getValue()}. 091 * 092 * @param value 093 * The supplier of the header value. 094 * <br>Can be <jk>null</jk>. 095 * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>. 096 */ 097 public static TransferEncoding of(Supplier<String> value) { 098 return value == null ? null : new TransferEncoding(value); 099 } 100 101 //----------------------------------------------------------------------------------------------------------------- 102 // Instance 103 //----------------------------------------------------------------------------------------------------------------- 104 105 /** 106 * Constructor. 107 * 108 * @param value 109 * The header value. 110 * <br>Can be <jk>null</jk>. 111 */ 112 public TransferEncoding(String value) { 113 super(NAME, value); 114 } 115 116 /** 117 * Constructor with delayed value. 118 * 119 * <p> 120 * Header value is re-evaluated on each call to {@link #getValue()}. 121 * 122 * @param value 123 * The supplier of the header value. 124 * <br>Can be <jk>null</jk>. 125 */ 126 public TransferEncoding(Supplier<String> value) { 127 super(NAME, value); 128 } 129}