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-Length</l> HTTP request/response header. 019 * 020 * <p> 021 * The length of the response body in octets (8-bit bytes). 022 * 023 * <h5 class='figure'>Example</h5> 024 * <p class='bcode w800'> 025 * Content-Length: 348 026 * </p> 027 * 028 * <h5 class='topic'>RFC2616 Specification</h5> 029 * 030 * The Content-Length entity-header field indicates the size of the entity-body, in decimal number of OCTETs, sent to 031 * the recipient or, in the case of the HEAD method, the size of the entity-body that would have been sent had the 032 * request been a GET. 033 * <p class='bcode w800'> 034 * Content-Length = "Content-Length" ":" 1*DIGIT 035 * </p> 036 * 037 * <p> 038 * An example is... 039 * <p class='bcode w800'> 040 * Content-Length: 3495 041 * </p> 042 * 043 * <p> 044 * Applications SHOULD use this field to indicate the transfer-length of the message-body, unless this is prohibited by 045 * the rules in section 4.4. 046 * 047 * <p> 048 * Any Content-Length greater than or equal to zero is a valid value. 049 * Section 4.4 describes how to determine the length of a message-body if a Content-Length is not given. 050 * 051 * <p> 052 * Note that the meaning of this field is significantly different from the corresponding definition in MIME, where it is 053 * an optional field used within the "message/external-body" content-type. 054 * In HTTP, it SHOULD be sent whenever the message's length can be determined prior to being transferred, unless this is 055 * prohibited by the rules in section 4.4. 056 * 057 * <ul class='seealso'> 058 * <li class='extlink'>{@doc RFC2616} 059 * </ul> 060 */ 061@Header("Content-Length") 062public final class ContentLength extends HeaderLong { 063 064 /** 065 * Constructor. 066 * 067 * @param value The value for this header. 068 */ 069 public ContentLength(Long value) { 070 super(value); 071 } 072 073 /** 074 * Returns a parsed <c>Content-Length</c> header. 075 * 076 * @param value The <c>Content-Length</c> header string. 077 * @return The parsed <c>Content-Length</c> header, or <jk>null</jk> if the string was null. 078 */ 079 public static ContentLength forString(String value) { 080 if (value == null) 081 return null; 082 return new ContentLength(value); 083 } 084 085 private ContentLength(String value) { 086 super(value); 087 } 088}