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>Accept-Range</l> HTTP response header. 025 * 026 * <p> 027 * What partial content range types this server supports via byte serving. 028 * 029 * <h5 class='figure'>Example</h5> 030 * <p class='bcode'> 031 * Accept-Ranges: bytes 032 * </p> 033 * 034 * <h5 class='topic'>RFC2616 Specification</h5> 035 * 036 * The Accept-Ranges response-header field allows the server to indicate its acceptance of range requests for a 037 * resource: 038 * <p class='bcode'> 039 * Accept-Ranges = "Accept-Ranges" ":" acceptable-ranges 040 * acceptable-ranges = 1#range-unit | "none" 041 * </p> 042 * 043 * <p> 044 * Origin servers that accept byte-range requests MAY send... 045 * <p class='bcode'> 046 * Accept-Ranges: bytes 047 * </p> 048 * <p> 049 * ...but are not required to do so. 050 * 051 * <p> 052 * Clients MAY generate byte-range requests without having received this header for the resource involved. 053 * 054 * <p> 055 * Range units are defined in section 3.12. 056 * 057 * <p> 058 * Servers that do not accept any kind of range request for a resource MAY send... 059 * <p class='bcode'> 060 * Accept-Ranges: none 061 * </p> 062 * <p> 063 * ...to advise the client not to attempt a range request. 064 * 065 * <h5 class='section'>See Also:</h5><ul> 066 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauRestCommonBasics">juneau-rest-common Basics</a> 067 * <li class='extlink'><a class="doclink" href="https://www.w3.org/Protocols/rfc2616/rfc2616.html">Hypertext Transfer Protocol -- HTTP/1.1</a> 068 * </ul> 069 * 070 * @serial exclude 071 */ 072@Header("Accept-Ranges") 073public class AcceptRanges extends BasicStringHeader { 074 private static final long serialVersionUID = 1L; 075 private static final String NAME = "Accept-Ranges"; 076 077 /** 078 * Static creator. 079 * 080 * @param value 081 * The header value. 082 * <br>Can be <jk>null</jk>. 083 * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>. 084 */ 085 public static AcceptRanges of(String value) { 086 return value == null ? null : new AcceptRanges(value); 087 } 088 089 /** 090 * Static creator with delayed value. 091 * 092 * <p> 093 * Header value is re-evaluated on each call to {@link #getValue()}. 094 * 095 * @param value 096 * The supplier of the header value. 097 * <br>Can be <jk>null</jk>. 098 * @return A new header bean, or <jk>null</jk> if the value is <jk>null</jk>. 099 */ 100 public static AcceptRanges of(Supplier<String> value) { 101 return value == null ? null : new AcceptRanges(value); 102 } 103 104 /** 105 * Constructor. 106 * 107 * @param value 108 * The header value. 109 * <br>Can be <jk>null</jk>. 110 */ 111 public AcceptRanges(String value) { 112 super(NAME, value); 113 } 114 115 /** 116 * Constructor with delayed value. 117 * 118 * <p> 119 * Header value is re-evaluated on each call to {@link #getValue()}. 120 * 121 * @param value 122 * The supplier of the header value. 123 * <br>Can be <jk>null</jk>. 124 */ 125 public AcceptRanges(Supplier<String> value) { 126 super(NAME, value); 127 } 128}