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