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.resource;
018
019import org.apache.http.*;
020import org.apache.juneau.http.header.*;
021
022/**
023 * An extension of an {@link HttpEntity} that also includes arbitrary headers.
024 *
025 * <p>
026 * While {@link HttpEntity} beans support <c>Content-Type</c>, <c>Content-Encoding</c>, and <c>Content-Length</c>
027 * headers, this interface allows you to add any number of arbitrary headers to an entity.
028 *
029 * <p>
030 * For example, you might want to be able to create an entity with a <c>Cache-Control</c> header.
031 *
032 * <p class='bjava'>
033 *    <jk>import static</jk> org.apache.juneau.http.HttpResources.*;
034 *
035 * <jc>// Create a resource with dynamic content and a no-cache header.</jc>
036 *    HttpResource <jv>myResource</jv> = <jsm>stringResource</jsm>(()-&gt;<jsm>getMyContent</jsm>(), ContentType.<jsf>TEXT_PLAIN</jsf>)
037 *       .header(<js>"Cache-Control"</js>, <js>"no-cache"</js>)
038 *       .build();
039 * </p>
040 *
041 * <h5 class='section'>See Also:</h5><ul>
042 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauRestCommonBasics">juneau-rest-common Basics</a>
043 * </ul>
044 */
045public interface HttpResource extends HttpEntity {
046
047   /**
048    * Returns the list of headers associated with this resource.
049    *
050    * <p>
051    * Note that this typically does NOT include headers associated with {@link HttpEntity}
052    * (e.g. <c>Content-Type</c>, <c>Content-Encoding</c>, and <c>Content-Length</c>).
053    *
054    * @return The list of headers associated with this resource.
055    */
056   HeaderList getHeaders();
057}