1/* Licensed to the Apache Software Foundation (ASF) under one or more 2 * contributor license agreements. See the NOTICE file distributed with 3 * this work for additional information regarding copyright ownership. 4 * The ASF licenses this file to You under the Apache License, Version 2.0 5 * (the "License"); you may not use this file except in compliance with 6 * the License. You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package java.net; 18 19import java.io.IOException; 20import java.io.InputStream; 21import java.util.List; 22import java.util.Map; 23 24/** 25 * A response cache entry. A {@code CacheResponse} object provides an {@code 26 * InputStream} to access the response body and a {@code Map} for the response headers. 27 * @see ResponseCache 28 */ 29public abstract class CacheResponse { 30 /** 31 * Returns an {@code InputStream} to access the response body. 32 * 33 * @return an {@code InputStream} which can be used to fetch the response 34 * body. 35 * @throws IOException 36 * if an I/O error is encountered while retrieving the response 37 * body. 38 */ 39 public abstract InputStream getBody() throws IOException; 40 41 /** 42 * Returns an immutable {@code Map} which contains the response headers 43 * information. Note that {@code URLConnection} may need the original headers to be 44 * able to fully reconstruct the response. In particular, failure to provide 45 * a mapping from null to the original HTTP status line will prevent an 46 * {@code HttpURLConnection} from returning the correct response code. 47 * See {@link URLConnection#getHeaderFields}. 48 * 49 * @return an immutable {@code Map} which contains the response headers. 50 * @throws IOException 51 * if an I/O error is encountered while retrieving the response 52 * headers. 53 */ 54 public abstract Map<String, List<String>> getHeaders() throws IOException; 55} 56