001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.http.header; 018 019import java.util.function.*; 020 021import org.apache.juneau.http.annotation.*; 022 023/** 024 * Represents a parsed <l>Transfer-Encoding</l> HTTP response header. 025 * 026 * <p> 027 * The form of encoding used to safely transfer the entity to the user. 028 * Currently defined methods are: chunked, compress, deflate, gzip, identity. 029 * 030 * <h5 class='figure'>Example</h5> 031 * <p class='bcode'> 032 * Transfer-Encoding: chunked 033 * </p> 034 * 035 * <h5 class='topic'>RFC2616 Specification</h5> 036 * 037 * The Transfer-Encoding general-header field indicates what (if any) type of transformation has been applied to the 038 * message body in order to safely transfer it between the sender and the recipient. 039 * This differs from the content-coding in that the transfer-coding is a property of the message, not of the entity. 040 * 041 * <p class='bcode'> 042 * Transfer-Encoding = "Transfer-Encoding" ":" 1#transfer-coding 043 * </p> 044 * 045 * <p> 046 * Transfer-codings are defined in section 3.6. An example is: 047 * 048 * <p class='bcode'> 049 * Transfer-Encoding: chunked 050 * </p> 051 * 052 * <p> 053 * If multiple encodings have been applied to an entity, the transfer-codings MUST be listed in the order in which 054 * they were applied. 055 * Additional information about the encoding parameters MAY be provided by other entity-header fields not defined by 056 * this specification. 057 * 058 * <p> 059 * Many older HTTP/1.0 applications do not understand the Transfer-Encoding header. 060 * 061 * <h5 class='section'>See Also:</h5><ul> 062 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauRestCommonBasics">juneau-rest-common Basics</a> 063 * <li class='extlink'><a class="doclink" href="https://www.w3.org/Protocols/rfc2616/rfc2616.html">Hypertext Transfer Protocol -- HTTP/1.1</a> 064 * </ul> 065 * 066 * @serial exclude 067 */ 068@Header("Transfer-Encoding") 069public class TransferEncoding extends BasicStringHeader { 070 private static final long serialVersionUID = 1L; 071 private static final String NAME = "Transfer-Encoding"; 072 073 /** 074 * Static creator. 075 * 076 * @param value 077 * The header value. 078 * <br>Can be <jk>null</jk>. 079 * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>. 080 */ 081 public static TransferEncoding of(String value) { 082 return value == null ? null : new TransferEncoding(value); 083 } 084 085 /** 086 * Static creator with delayed value. 087 * 088 * <p> 089 * Header value is re-evaluated on each call to {@link #getValue()}. 090 * 091 * @param value 092 * The supplier of the header value. 093 * <br>Can be <jk>null</jk>. 094 * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>. 095 */ 096 public static TransferEncoding of(Supplier<String> value) { 097 return value == null ? null : new TransferEncoding(value); 098 } 099 100 /** 101 * Constructor. 102 * 103 * @param value 104 * The header value. 105 * <br>Can be <jk>null</jk>. 106 */ 107 public TransferEncoding(String value) { 108 super(NAME, value); 109 } 110 111 /** 112 * Constructor with delayed value. 113 * 114 * <p> 115 * Header value is re-evaluated on each call to {@link #getValue()}. 116 * 117 * @param value 118 * The supplier of the header value. 119 * <br>Can be <jk>null</jk>. 120 */ 121 public TransferEncoding(Supplier<String> value) { 122 super(NAME, value); 123 } 124}