001    /*
002     * Copyright 1999-2001,2004 The Apache Software Foundation.
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package org.apache.commons.latka.http;
018    
019    import java.io.InputStream;
020    
021    /**
022     * A Latka Response represents a response from an HTTP server.
023     *
024     * @author <a href="mailto:dsale@us.britannica.com">Doug Sale</a>
025     * @author <a href="mailto:mdelagra@us.britannica.com">Morgan Delagrange</a>
026     */
027    public interface Response {
028    
029      /**
030       * @return the integer status code provided by the HTTP server.
031       */
032      int getStatusCode();
033    
034      /**
035       * @return the status text (or "reason phrase") associated with the response.
036       */
037      String getStatusText();
038    
039      /**
040       * Returns the resource, in string form, 
041       * provided by the HTTP server
042       * 
043       * @return the contents of the HTTP response body has a String,
044       *         or null if there was no response body
045       */
046      String getResource();
047    
048      /**
049       * Get the actual bytes returned by the web server
050       * 
051       * @return InputStream containing the HTTP response, or null
052       *         if the response contains no body
053       */
054      InputStream getStream();
055    
056      /**
057       * Returns the length of the Response stream (as bytes),
058       * or -1 if no stream is available
059       * 
060       * @return Byte length of the response stream
061       */
062      int getByteLength();
063    
064      /**
065       * Getter for request property
066       * @return the request that generated this response
067       */
068      Request getRequest();
069    
070      /**
071       * Check a response header.  If more than one header
072       * of the same name is encountered, they are collapsed
073       * into one comma-separated String.
074       * 
075       * @param headerName The name of the header to find in the Reponse
076       * @return the value of the header(s), or null if the header does not
077       *         exist
078       */
079      String getHeader(String headerName);
080    }