Interface RoResponse
- All Known Implementing Classes:
Response
public interface RoResponse
This interface represents read-only interface of an intermediate http
response. It is the compile-time type passed to various handlers which might
the response info but musn't modify the response.
- Version:
- 0.3-3 06/05/2001
- Author:
- Ronald Tschal�r
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]getData()Reads all the response data into a byte array.retrieves the field for a given header.getHeaderAsDate(String hdr) retrieves the field for a given header.intgetHeaderAsInt(String hdr) retrieves the field for a given header.Gets an input stream from which the returned data can be read.intgive the status code for this request.getTrailer(String trailer) Retrieves the field for a given trailer.getTrailerAsDate(String trailer) Retrieves the field for a given trailer.intgetTrailerAsInt(String trailer) Retrieves the field for a given tailer.
-
Method Details
-
getStatusCode
give the status code for this request. These are grouped as follows:- 1xx - Informational (new in HTTP/1.1)
- 2xx - Success
- 3xx - Redirection
- 4xx - Client Error
- 5xx - Server Error
- Returns:
- the status code
- Throws:
IOException- If any exception occurs on the socket.
-
getReasonLine
- Returns:
- the reason line associated with the status code.
- Throws:
IOException- If any exception occurs on the socket.
-
getVersion
- Returns:
- the HTTP version returned by the server.
- Throws:
IOException- If any exception occurs on the socket.
-
getHeader
retrieves the field for a given header.- Parameters:
hdr- the header name.- Returns:
- the value for the header, or null if non-existent.
- Throws:
IOException- If any exception occurs on the socket.
-
getHeaderAsInt
retrieves the field for a given header. The value is parsed as an int.- Parameters:
hdr- the header name.- Returns:
- the value for the header if the header exists
- Throws:
NumberFormatException- if the header's value is not a number or if the header does not exist.IOException- if any exception occurs on the socket.
-
getHeaderAsDate
retrieves the field for a given header. The value is parsed as a date; if this fails it is parsed as a long representing the number of seconds since 12:00 AM, Jan 1st, 1970. If this also fails an IllegalArgumentException is thrown.- Parameters:
hdr- the header name.- Returns:
- the value for the header, or null if non-existent.
- Throws:
IOException- If any exception occurs on the socket.IllegalArgumentException- If the header cannot be parsed as a date or time.
-
getTrailer
Retrieves the field for a given trailer. Note that this should not be invoked until all the response data has been read. If invoked before, it will force the data to be read viagetData().- Parameters:
trailer- the trailer name.- Returns:
- the value for the trailer, or null if non-existent.
- Throws:
IOException- If any exception occurs on the socket.
-
getTrailerAsInt
Retrieves the field for a given tailer. The value is parsed as an int.- Parameters:
trailer- the tailer name.- Returns:
- the value for the trailer if the trailer exists
- Throws:
NumberFormatException- if the trailer's value is not a number or if the trailer does not exist.IOException- if any exception occurs on the socket.
-
getTrailerAsDate
Retrieves the field for a given trailer. The value is parsed as a date; if this fails it is parsed as a long representing the number of seconds since 12:00 AM, Jan 1st, 1970. If this also fails an IllegalArgumentException is thrown.
Note: When sending dates use Util.httpDate().- Parameters:
trailer- the trailer name.- Returns:
- the value for the trailer, or null if non-existent.
- Throws:
IllegalArgumentException- if the trailer's value is neither a legal date nor a number.IOException- if any exception occurs on the socket.IllegalArgumentException- If the header cannot be parsed as a date or time.
-
getData
Reads all the response data into a byte array. Note that this method won't return until all the data has been received (so for instance don't invoke this method if the server is doing a server push). If getInputStream() had been previously called then this method only returns any unread data remaining on the stream and then closes it.- Returns:
- an array containing the data (body) returned. If no data was returned then it's set to a zero-length array.
- Throws:
IOException- If any io exception occured while reading the data- See Also:
-
getInputStream
Gets an input stream from which the returned data can be read. Note that if getData() had been previously called it will actually return a ByteArrayInputStream created from that data.- Returns:
- the InputStream.
- Throws:
IOException- If any exception occurs on the socket.- See Also:
-