1 /* 2 * Copyright 1999-2001,2004 The Apache Software Foundation. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * 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 17 package org.apache.commons.latka.http; 18 19 import java.io.InputStream; 20 21 /** 22 * A Latka Response represents a response from an HTTP server. 23 * 24 * @author <a href="mailto:dsale@us.britannica.com">Doug Sale</a> 25 * @author <a href="mailto:mdelagra@us.britannica.com">Morgan Delagrange</a> 26 */ 27 public interface Response { 28 29 /** 30 * @return the integer status code provided by the HTTP server. 31 */ 32 int getStatusCode(); 33 34 /** 35 * @return the status text (or "reason phrase") associated with the response. 36 */ 37 String getStatusText(); 38 39 /** 40 * Returns the resource, in string form, 41 * provided by the HTTP server 42 * 43 * @return the contents of the HTTP response body has a String, 44 * or null if there was no response body 45 */ 46 String getResource(); 47 48 /** 49 * Get the actual bytes returned by the web server 50 * 51 * @return InputStream containing the HTTP response, or null 52 * if the response contains no body 53 */ 54 InputStream getStream(); 55 56 /** 57 * Returns the length of the Response stream (as bytes), 58 * or -1 if no stream is available 59 * 60 * @return Byte length of the response stream 61 */ 62 int getByteLength(); 63 64 /** 65 * Getter for request property 66 * @return the request that generated this response 67 */ 68 Request getRequest(); 69 70 /** 71 * Check a response header. If more than one header 72 * of the same name is encountered, they are collapsed 73 * into one comma-separated String. 74 * 75 * @param headerName The name of the header to find in the Reponse 76 * @return the value of the header(s), or null if the header does not 77 * exist 78 */ 79 String getHeader(String headerName); 80 }