1 // 2 // ======================================================================== 3 // Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd. 4 // ------------------------------------------------------------------------ 5 // All rights reserved. This program and the accompanying materials 6 // are made available under the terms of the Eclipse Public License v1.0 7 // and Apache License v2.0 which accompanies this distribution. 8 // 9 // The Eclipse Public License is available at 10 // http://www.eclipse.org/legal/epl-v10.html 11 // 12 // The Apache License v2.0 is available at 13 // http://www.opensource.org/licenses/apache2.0.php 14 // 15 // You may elect to redistribute this code under either of these licenses. 16 // ======================================================================== 17 // 18 19 package org.eclipse.jetty.http; 20 21 import java.io.IOException; 22 import java.io.InputStream; 23 import java.nio.ByteBuffer; 24 import java.nio.channels.ReadableByteChannel; 25 26 import org.eclipse.jetty.http.MimeTypes.Type; 27 import org.eclipse.jetty.util.resource.Resource; 28 29 /* ------------------------------------------------------------ */ 30 /** HttpContent interface. 31 * <p>This information represents all the information about a 32 * static resource that is needed to evaluate conditional headers 33 * and to serve the content if need be. It can be implemented 34 * either transiently (values and fields generated on demand) or 35 * persistently (values and fields pre-generated in anticipation of 36 * reuse in from a cache). 37 * </p> 38 * 39 */ 40 public interface HttpContent 41 { 42 HttpField getContentType(); 43 String getContentTypeValue(); 44 String getCharacterEncoding(); 45 Type getMimeType(); 46 47 HttpField getContentEncoding(); 48 String getContentEncodingValue(); 49 50 HttpField getContentLength(); 51 long getContentLengthValue(); 52 53 HttpField getLastModified(); 54 String getLastModifiedValue(); 55 56 HttpField getETag(); 57 String getETagValue(); 58 59 ByteBuffer getIndirectBuffer(); 60 ByteBuffer getDirectBuffer(); 61 Resource getResource(); 62 InputStream getInputStream() throws IOException; 63 ReadableByteChannel getReadableByteChannel() throws IOException; 64 void release(); 65 66 HttpContent getGzipContent(); 67 68 69 public interface Factory 70 { 71 /** 72 * @param path The path within the context to the resource 73 * @param maxBuffer The maximum buffer to allocated for this request. For cached content, a larger buffer may have 74 * previously been allocated and returned by the {@link HttpContent#getDirectBuffer()} or {@link HttpContent#getIndirectBuffer()} calls. 75 * @return A {@link HttpContent} 76 * @throws IOException 77 */ 78 HttpContent getContent(String path,int maxBuffer) throws IOException; 79 } 80 }