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