001 /*
002 * The contents of this file are subject to the terms
003 * of the Common Development and Distribution License
004 * (the "License"). You may not use this file except
005 * in compliance with the License.
006 *
007 * You can obtain a copy of the license at
008 * http://www.opensource.org/licenses/cddl1.php
009 * See the License for the specific language governing
010 * permissions and limitations under the License.
011 */
012 /*
013 * HttpHeaders.java
014 *
015 * Created on April 13, 2007, 3:00 PM
016 *
017 */
018
019 package javax.ws.rs.core;
020
021 import java.util.List;
022 import java.util.Locale;
023 import java.util.Map;
024
025 /**
026 * An injectable interface that provides access to HTTP header information.
027 * All methods throw java.lang.IllegalStateException if called outside the scope of a request
028 * (e.g. from a provider constructor).
029 * @see Context
030 */
031 public interface HttpHeaders {
032
033 /**
034 * Get the values of a HTTP request header. The returned List is read-only.
035 * This is a shortcut for <code>getRequestHeaders().get(name)</code>.
036 * @param name the header name, case insensitive
037 * @return a read-only list of header values.
038 * @throws java.lang.IllegalStateException if called outside the scope of a request
039 */
040 public List<String> getRequestHeader(String name);
041
042 /**
043 * Get the values of HTTP request headers. The returned Map is case-insensitive
044 * wrt keys and is read-only.
045 * @return a read-only map of header names and values.
046 * @throws java.lang.IllegalStateException if called outside the scope of a request
047 */
048 public MultivaluedMap<String, String> getRequestHeaders();
049
050 /**
051 * Get a list of media types that are acceptable for the response.
052 * @return a read-only list of requested response media types sorted according
053 * to their q-value, with highest preference first.
054 * @throws java.lang.IllegalStateException if called outside the scope of a request
055 */
056 public List<MediaType> getAcceptableMediaTypes();
057
058 /**
059 * Get a list of languages that are acceptable for the response.
060 * @return a read-only list of acceptable languages sorted according
061 * to their q-value, with highest preference first.
062 * @throws java.lang.IllegalStateException if called outside the scope of a request
063 */
064 public List<Locale> getAcceptableLanguages();
065
066 /**
067 * Get the media type of the request entity
068 * @return the media type or null if there is no request entity.
069 * @throws java.lang.IllegalStateException if called outside the scope of a request
070 */
071 public MediaType getMediaType();
072
073 /**
074 * Get the language of the request entity
075 * @return the language of the entity or null if not specified
076 * @throws java.lang.IllegalStateException if called outside the scope of a request
077 */
078 public Locale getLanguage();
079
080 /**
081 * Get any cookies that accompanied the request.
082 * @return a read-only map of cookie name (String) to Cookie.
083 * @throws java.lang.IllegalStateException if called outside the scope of a request
084 */
085 public Map<String, Cookie> getCookies();
086
087 /**
088 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">HTTP/1.1 documentation</a>}.
089 */
090 public static final String ACCEPT = "Accept";
091
092 /**
093 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.2">HTTP/1.1 documentation</a>}.
094 */
095 public static final String ACCEPT_CHARSET = "Accept-Charset";
096
097 /**
098 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3">HTTP/1.1 documentation</a>}.
099 */
100 public static final String ACCEPT_ENCODING = "Accept-Encoding";
101
102 /**
103 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4">HTTP/1.1 documentation</a>}.
104 */
105 public static final String ACCEPT_LANGUAGE = "Accept-Language";
106
107 /**
108 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.8">HTTP/1.1 documentation</a>}.
109 */
110 public static final String AUTHORIZATION = "Authorization";
111
112 /**
113 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9">HTTP/1.1 documentation</a>}.
114 */
115 public static final String CACHE_CONTROL = "Cache-Control";
116
117 /**
118 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11">HTTP/1.1 documentation</a>}.
119 */
120 public static final String CONTENT_ENCODING = "Content-Encoding";
121
122 /**
123 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.12">HTTP/1.1 documentation</a>}.
124 */
125 public static final String CONTENT_LANGUAGE = "Content-Language";
126
127 /**
128 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13">HTTP/1.1 documentation</a>}.
129 */
130 public static final String CONTENT_LENGTH = "Content-Length";
131
132 /**
133 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.14">HTTP/1.1 documentation</a>}.
134 */
135 public static final String CONTENT_LOCATION = "Content-Location";
136
137 /**
138 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17">HTTP/1.1 documentation</a>}.
139 */
140 public static final String CONTENT_TYPE = "Content-Type";
141
142 /**
143 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.18">HTTP/1.1 documentation</a>}.
144 */
145 public static final String DATE = "Date";
146
147 /**
148 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.19">HTTP/1.1 documentation</a>}.
149 */
150 public static final String ETAG = "ETag";
151
152 /**
153 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.21">HTTP/1.1 documentation</a>}.
154 */
155 public static final String EXPIRES = "Expires";
156
157 /**
158 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23">HTTP/1.1 documentation</a>}.
159 */
160 public static final String HOST = "Host";
161
162 /**
163 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.24">HTTP/1.1 documentation</a>}.
164 */
165 public static final String IF_MATCH = "If-Match";
166
167 /**
168 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.25">HTTP/1.1 documentation</a>}.
169 */
170 public static final String IF_MODIFIED_SINCE = "If-Modified-Since";
171
172 /**
173 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.26">HTTP/1.1 documentation</a>}.
174 */
175 public static final String IF_NONE_MATCH = "If-None-Match";
176
177 /**
178 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.28">HTTP/1.1 documentation</a>}.
179 */
180 public static final String IF_UNMODIFIED_SINCE = "If-Unmodified-Since";
181
182 /**
183 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.29">HTTP/1.1 documentation</a>}.
184 */
185 public static final String LAST_MODIFIED = "Last-Modified";
186
187 /**
188 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30">HTTP/1.1 documentation</a>}.
189 */
190 public static final String LOCATION = "Location";
191
192 /**
193 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43">HTTP/1.1 documentation</a>}.
194 */
195 public static final String USER_AGENT = "User-Agent";
196
197 /**
198 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.44">HTTP/1.1 documentation</a>}.
199 */
200 public static final String VARY = "Vary";
201
202 /**
203 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.47">HTTP/1.1 documentation</a>}.
204 */
205 public static final String WWW_AUTHENTICATE = "WWW-Authenticate";
206
207 /**
208 * See {@link <a href="http://www.ietf.org/rfc/rfc2109.txt">IETF RFC 2109</a>}.
209 */
210 public static final String COOKIE = "Cookie";
211
212 /**
213 * See {@link <a href="http://www.ietf.org/rfc/rfc2109.txt">IETF RFC 2109</a>}.
214 */
215 public static final String SET_COOKIE = "Set-Cookie";
216
217 }