|
Oracle Application Server HTTPClient API Reference 10g Release 2 (10.1.2) B14020-02 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
HTTPClient.HTTPResponse
This defines the http-response class returned by the requests. It's basically a wrapper around the Response class which first lets all the modules handle the response before finally giving the info to the user.
Field Summary |
Fields inherited from interface HTTPClient.HTTPClientModuleConstants |
REQ_CONTINUE, REQ_NEWCON_RST, REQ_NEWCON_SND, REQ_RESPONSE, REQ_RESTART, REQ_RETURN, REQ_SHORTCIRC, RSP_CONTINUE, RSP_NEWCON_REQ, RSP_NEWCON_SND, RSP_REQUEST, RSP_RESTART, RSP_SEND, RSP_SHORTCIRC |
Method Summary | |
byte[] |
getData() Reads all the response data into a byte array. |
URI |
getEffectiveURI() Get the final URI of the document. |
java.net.URL |
getEffectiveURL() Deprecated. use getEffectiveURI() instead |
java.lang.String |
getHeader(java.lang.String hdr) Retrieves the value for a given header. |
java.util.Date |
getHeaderAsDate(java.lang.String hdr) Retrieves the value for a given header. |
int |
getHeaderAsInt(java.lang.String hdr) Retrieves the value for a given header. |
java.io.InputStream |
getInputStream() Gets an input stream from which the returned data can be read. |
int |
getNumberOfPhysicalConnections() Get the number of socket connections created for this request-response |
URI |
getOriginalURI() Get the original URI used in the request. |
java.lang.String |
getReasonLine() Give the reason line associated with the status code. |
java.lang.String |
getServer() Deprecated. This method is a remnant of V0.1; use getHeader("Server") instead. |
int |
getStatusCode() Give the status code for this request. |
java.lang.String |
getText() Reads all the response data into a buffer and turns it into a string using the appropriate character converter. |
java.lang.String |
getTrailer(java.lang.String trailer) Retrieves the value for a given trailer. |
java.util.Date |
getTrailerAsDate(java.lang.String trailer) Retrieves the value for a given trailer. |
int |
getTrailerAsInt(java.lang.String trailer) Retrieves the value for a given tailer. |
java.lang.String |
getVersion() Get the HTTP version used for the response. |
java.util.Enumeration |
listHeaders() Returns an enumeration of all the headers available via getHeader(). |
java.util.Enumeration |
listTrailers() Returns an enumeration of all the trailers available via getTrailer(). |
boolean |
retryRequest() Should the request be retried by the application? If the application used an HttpOutputStream in the request then various modules (such as the redirection and authorization modules) are not able to resend the request themselves. |
java.lang.String |
toString() produces a full list of headers and their values, one per line. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
public final int getStatusCode() throws java.io.IOException, ModuleException
java.io.IOException
- if any exception occurs on the socket.ModuleException
- if any module encounters an exception.public final java.lang.String getReasonLine() throws java.io.IOException, ModuleException
java.io.IOException
- If any exception occurs on the socket.ModuleException
- if any module encounters an exception.public final java.lang.String getVersion() throws java.io.IOException, ModuleException
java.io.IOException
- If any exception occurs on the socket.ModuleException
- if any module encounters an exception.public final java.lang.String getServer() throws java.io.IOException, ModuleException
getHeader("Server")
instead.java.io.IOException
- If any exception occurs on the socket.ModuleException
- if any module encounters an exception.getHeader(java.lang.String)
public int getNumberOfPhysicalConnections()
public final URI getOriginalURI()
public final java.net.URL getEffectiveURL() throws java.io.IOException, ModuleException
java.io.IOException
- If any exception occurs on the socket.ModuleException
- if any module encounters an exception.getEffectiveURI()
public final URI getEffectiveURI() throws java.io.IOException, ModuleException
java.io.IOException
- If any exception occurs on the socket.ModuleException
- if any module encounters an exception.public java.lang.String getHeader(java.lang.String hdr) throws java.io.IOException, ModuleException
hdr
- the header name.java.io.IOException
- If any exception occurs on the socket.ModuleException
- if any module encounters an exception.public int getHeaderAsInt(java.lang.String hdr) throws java.io.IOException, ModuleException, java.lang.NumberFormatException
hdr
- the header name.java.lang.NumberFormatException
- if the header's value is not a number or if the header does not exist.java.io.IOException
- if any exception occurs on the socket.ModuleException
- if any module encounters an exception.public java.util.Date getHeaderAsDate(java.lang.String hdr) throws java.io.IOException, java.lang.IllegalArgumentException, ModuleException
hdr
- the header name.java.lang.IllegalArgumentException
- if the header's value is neither a legal date nor a number.java.io.IOException
- if any exception occurs on the socket.ModuleException
- if any module encounters an exception.public java.util.Enumeration listHeaders() throws java.io.IOException, ModuleException
java.io.IOException
- If any exception occurs on the socket.ModuleException
- if any module encounters an exception.public java.lang.String getTrailer(java.lang.String trailer) throws java.io.IOException, ModuleException
getData()
to force the data to be read.trailer
- the trailer name.java.io.IOException
- If any exception occurs on the socket.ModuleException
- if any module encounters an exception.getData()
public int getTrailerAsInt(java.lang.String trailer) throws java.io.IOException, ModuleException, java.lang.NumberFormatException
trailer
- the tailer name.java.lang.NumberFormatException
- if the trailer's value is not a number or if the trailer does not exist.java.io.IOException
- if any exception occurs on the socket.ModuleException
- if any module encounters an exception.public java.util.Date getTrailerAsDate(java.lang.String trailer) throws java.io.IOException, java.lang.IllegalArgumentException, ModuleException
trailer
- the trailer name.java.lang.IllegalArgumentException
- if the trailer's value is neither a legal date nor a number.java.io.IOException
- if any exception occurs on the socket.ModuleException
- if any module encounters an exception.public java.util.Enumeration listTrailers() throws java.io.IOException, ModuleException
java.io.IOException
- If any exception occurs on the socket.ModuleException
- if any module encounters an exception.public byte[] getData() throws java.io.IOException, ModuleException
getInputStream()
had been previously invoked then this method only returns any unread data remaining on the stream and then closes it.
Note to the unwary: code like
System.out.println("The data: " + resp.getData())will probably not do what you want - use
System.out.println("The data: " + resp.getText())instead.
java.io.IOException
- If any io exception occured while reading the dataModuleException
- if any module encounters an exception.getInputStream()
public java.lang.String getText() throws java.io.IOException, ModuleException, ParseException
getData()
, the caveats of that method apply here as well.java.io.IOException
- If any io exception occured while reading the data, or if the content is not textModuleException
- if any module encounters an exception.ParseException
- if an error occured trying to parse the content-type header fieldgetData()
public java.io.InputStream getInputStream() throws java.io.IOException, ModuleException
getData()
had been previously invoked it will actually return a ByteArrayInputStream created from that data.java.io.IOException
- If any exception occurs on the socket.ModuleException
- if any module encounters an exception.getData()
public boolean retryRequest() throws java.io.IOException, ModuleException
If the application resends the request then it must use the same HttpOutputStream instance. This is because the modules use this to recognize the retried request and to perform the necessary work on the request before it's sent.
Here is a skeleton example of usage:
OutputStream out = new HttpOutputStream(1234); do { rsp = con.Post("/cgi-bin/my_cgi", out); out.write(...); out.close(); } while (rsp.retryRequest()); if (rsp.getStatusCode() >= 300) ...
Note that for this to ever return true, the java system property HTTPClient.deferStreamed must be set to true at the beginning of the application (before the HTTPConnection class is loaded). This prevents unwary applications from causing inadvertent memory leaks. If an application does set this, then it must resend any request whose response returns true here in order to prevent memory leaks (a switch to JDK 1.2 will allow us to use weak references and eliminate this problem).
java.io.IOException
- If any exception occurs on the socket.ModuleException
- if any module encounters an exception.public java.lang.String toString()
|
Oracle Application Server HTTPClient API Reference 10g Release 2 (10.1.2) B14020-02 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |