|
|||||||||
| Home >> All >> [ HTTPClient overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
HTTPClient
Class HTTPResponse

java.lang.ObjectHTTPClient.HTTPResponse
- All Implemented Interfaces:
- GlobalConstants, HTTPClientModuleConstants
- public class HTTPResponse
- extends java.lang.Object
- implements GlobalConstants, HTTPClientModuleConstants
- extends java.lang.Object
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.
- Since:
- 0.3
- Version:
- 0.3-2 18/06/1999
| Field Summary | |
private boolean |
aborted
marks this response as aborted (stop() in HTTPConnection) |
static int |
CD_0
|
static int |
CD_CHUNKED
|
static int |
CD_CLOSE
|
static int |
CD_CONTLEN
|
static int |
CD_HDRS
|
static int |
CD_MP_BR
|
static int |
CD_NONE
Content delimiters |
private int |
ContentLength
the ContentLength of the data. |
private byte[] |
Data
the data (body) returned. |
static boolean |
DebugAll
Debug variables |
static boolean |
DebugAuth
|
static boolean |
DebugConn
|
static boolean |
DebugDemux
|
static boolean |
DebugMods
|
static boolean |
DebugResp
|
static boolean |
DebugSocks
|
static boolean |
DebugURLC
|
private URI |
EffectiveURI
the final URI of the document. |
private boolean |
got_trailers
signals if we have got the trailers yet? |
private boolean |
handle_trailers
|
private CIHashtable |
Headers
any headers which were received and do not fit in the above list. |
static int |
HTTP
possible http protocols we (might) handle |
static int |
HTTP_1_0
some known http versions |
static int |
HTTP_1_1
|
static int |
HTTP_NG
|
static int |
HTTPS
|
private boolean |
initialized
signals if we have got and parsed the headers yet? |
private java.io.InputStream |
inp_stream
our input stream from the stream demux |
private java.lang.String |
method
the method used in the request |
private HTTPClientModule[] |
modules
the list of modules |
private URI |
OriginalURI
the original URI used. |
private HttpOutputStream |
out_stream
the HttpOutputStream to synchronize on |
private java.lang.String |
ReasonLine
the reason line associated with the status code. |
private Request |
request
the request |
private Response |
response
the current response |
static int |
SHTTP
|
private int |
StatusCode
the status code returned. |
private int |
timeout
the timeout for reads |
private CIHashtable |
Trailers
any trailers which were received and do not fit in the above list. |
private boolean |
trailers_handled
|
private java.lang.String |
Version
the HTTP version of the response. |
| 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 |
| Constructor Summary | |
(package private) |
HTTPResponse(HTTPClientModule[] modules,
int timeout,
Request orig)
Creates a new HTTPResponse. |
| 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. |
(package private) HTTPClientModule[] |
getModules()
|
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. |
(package private) int |
getTimeout()
|
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. |
private void |
getTrailers()
Gets any trailers from the response if we haven't already done so. |
java.lang.String |
getVersion()
Get the HTTP version used for the response. |
(package private) boolean |
handleResponse()
Processes a Response. |
(package private) void |
init(Response resp)
Copies the relevant fields from Response and marks this as initialized. |
(package private) void |
invokeTrailerHandlers(boolean force)
This is invoked by the RespInputStream when it is close()'d. |
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(). |
(package private) void |
markAborted()
Mark this request as having been aborted. |
private void |
readResponseData(java.io.InputStream inp)
Reads the response data received. |
(package private) void |
set(Request req,
HttpOutputStream out_stream)
|
(package private) void |
set(Request req,
Response resp)
|
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 |
| Field Detail |
modules
private HTTPClientModule[] modules
- the list of modules
timeout
private int timeout
- the timeout for reads
request
private Request request
- the request
response
private Response response
- the current response
out_stream
private HttpOutputStream out_stream
- the HttpOutputStream to synchronize on
inp_stream
private java.io.InputStream inp_stream
- our input stream from the stream demux
StatusCode
private int StatusCode
- the status code returned.
ReasonLine
private java.lang.String ReasonLine
- the reason line associated with the status code.
Version
private java.lang.String Version
- the HTTP version of the response.
OriginalURI
private URI OriginalURI
- the original URI used.
EffectiveURI
private URI EffectiveURI
- the final URI of the document.
Headers
private CIHashtable Headers
- any headers which were received and do not fit in the above list.
Trailers
private CIHashtable Trailers
- any trailers which were received and do not fit in the above list.
ContentLength
private int ContentLength
- the ContentLength of the data.
Data
private byte[] Data
- the data (body) returned.
initialized
private boolean initialized
- signals if we have got and parsed the headers yet?
got_trailers
private boolean got_trailers
- signals if we have got the trailers yet?
aborted
private boolean aborted
- marks this response as aborted (stop() in HTTPConnection)
method
private java.lang.String method
- the method used in the request
handle_trailers
private boolean handle_trailers
trailers_handled
private boolean trailers_handled
DebugAll
public static final boolean DebugAll
- Debug variables
- See Also:
- Constant Field Values
DebugConn
public static final boolean DebugConn
- See Also:
- Constant Field Values
DebugResp
public static final boolean DebugResp
- See Also:
- Constant Field Values
DebugDemux
public static final boolean DebugDemux
- See Also:
- Constant Field Values
DebugAuth
public static final boolean DebugAuth
- See Also:
- Constant Field Values
DebugSocks
public static final boolean DebugSocks
- See Also:
- Constant Field Values
DebugMods
public static final boolean DebugMods
- See Also:
- Constant Field Values
DebugURLC
public static final boolean DebugURLC
- See Also:
- Constant Field Values
HTTP
public static final int HTTP
- possible http protocols we (might) handle
- See Also:
- Constant Field Values
HTTPS
public static final int HTTPS
- See Also:
- Constant Field Values
SHTTP
public static final int SHTTP
- See Also:
- Constant Field Values
HTTP_NG
public static final int HTTP_NG
- See Also:
- Constant Field Values
HTTP_1_0
public static final int HTTP_1_0
- some known http versions
- See Also:
- Constant Field Values
HTTP_1_1
public static final int HTTP_1_1
- See Also:
- Constant Field Values
CD_NONE
public static final int CD_NONE
- Content delimiters
- See Also:
- Constant Field Values
CD_HDRS
public static final int CD_HDRS
- See Also:
- Constant Field Values
CD_0
public static final int CD_0
- See Also:
- Constant Field Values
CD_CLOSE
public static final int CD_CLOSE
- See Also:
- Constant Field Values
CD_CONTLEN
public static final int CD_CONTLEN
- See Also:
- Constant Field Values
CD_CHUNKED
public static final int CD_CHUNKED
- See Also:
- Constant Field Values
CD_MP_BR
public static final int CD_MP_BR
- See Also:
- Constant Field Values
| Constructor Detail |
HTTPResponse
HTTPResponse(HTTPClientModule[] modules, int timeout, Request orig)
- Creates a new HTTPResponse.
| Method Detail |
set
void set(Request req, Response resp)
set
void set(Request req, HttpOutputStream out_stream)
getStatusCode
public final int getStatusCode()
throws java.io.IOException,
ModuleException
- 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
getReasonLine
public final java.lang.String getReasonLine() throws java.io.IOException, ModuleException
- Give the reason line associated with the status code.
getVersion
public final java.lang.String getVersion() throws java.io.IOException, ModuleException
- Get the HTTP version used for the response.
getServer
public final java.lang.String getServer() throws java.io.IOException, ModuleException
- Deprecated. This method is a remnant of V0.1; use
getHeader("Server")instead.- Get the name and type of server.
- Get the name and type of server.
getOriginalURI
public final URI getOriginalURI()
- Get the original URI used in the request.
getEffectiveURL
public final java.net.URL getEffectiveURL() throws java.io.IOException, ModuleException
- Deprecated. use getEffectiveURI() instead
- Get the final URL of the document. This is set if the original request was deferred via the "moved" (301, 302, or 303) return status.
- Get the final URL of the document. This is set if the original request was deferred via the "moved" (301, 302, or 303) return status.
getEffectiveURI
public final URI getEffectiveURI() throws java.io.IOException, ModuleException
- Get the final URI of the document. If the request was redirected
via the "moved" (301, 302, 303, or 307) return status this returns
the URI used in the last redirection; otherwise it returns the
original URI.
getHeader
public java.lang.String getHeader(java.lang.String hdr) throws java.io.IOException, ModuleException
- Retrieves the value for a given header.
getHeaderAsInt
public int getHeaderAsInt(java.lang.String hdr) throws java.io.IOException, ModuleException, java.lang.NumberFormatException
- Retrieves the value for a given header. The value is parsed as an
int.
getHeaderAsDate
public java.util.Date getHeaderAsDate(java.lang.String hdr) throws java.io.IOException, java.lang.IllegalArgumentException, ModuleException
- Retrieves the value 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
exception is thrown.
Note: When sending dates use Util.httpDate().
listHeaders
public java.util.Enumeration listHeaders() throws java.io.IOException, ModuleException
- Returns an enumeration of all the headers available via getHeader().
getTrailer
public java.lang.String getTrailer(java.lang.String trailer) throws java.io.IOException, ModuleException
- Retrieves the value for a given trailer. This should not be invoked
until all response data has been read. If invoked before it will
call
getData()to force the data to be read.
getTrailerAsInt
public int getTrailerAsInt(java.lang.String trailer) throws java.io.IOException, ModuleException, java.lang.NumberFormatException
- Retrieves the value for a given tailer. The value is parsed as an
int.
getTrailerAsDate
public java.util.Date getTrailerAsDate(java.lang.String trailer) throws java.io.IOException, java.lang.IllegalArgumentException, ModuleException
- Retrieves the value 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().
listTrailers
public java.util.Enumeration listTrailers() throws java.io.IOException, ModuleException
- Returns an enumeration of all the trailers available via getTrailer().
getData
public byte[] getData()
throws java.io.IOException,
ModuleException
- 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 invoked then this method only returns any unread data remaining on the stream and then closes it.Note to the unwarry: code like
System.out.println("The data: " + resp.getData())will probably not do what you want - useSystem.out.println("The data: " + new String(resp.getData()))instead.
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOException, ModuleException
- Gets an input stream from which the returned data can be read. Note
that if
getData()had been previously invoked it will actually return a ByteArrayInputStream created from that data.
toString
public java.lang.String toString()
- produces a full list of headers and their values, one per line.
getModules
HTTPClientModule[] getModules()
handleResponse
boolean handleResponse()
throws java.io.IOException,
ModuleException
- Processes a Response. This is done by calling the response handler
in each module. When all is done, the various fields of this instance
are intialized from the last Response.
init
void init(Response resp)
- Copies the relevant fields from Response and marks this as initialized.
invokeTrailerHandlers
void invokeTrailerHandlers(boolean force)
throws java.io.IOException,
ModuleException
- This is invoked by the RespInputStream when it is close()'d. It
just invokes the trailer handler in each module.
markAborted
void markAborted()
- Mark this request as having been aborted. It's invoked by
HTTPConnection.stop().
getTrailers
private void getTrailers()
throws java.io.IOException,
ModuleException
- Gets any trailers from the response if we haven't already done so.
readResponseData
private void readResponseData(java.io.InputStream inp) throws java.io.IOException, ModuleException
- Reads the response data received. Does not return until either
Content-Length bytes have been read or EOF is reached.
getTimeout
int getTimeout()
|
|||||||||
| Home >> All >> [ HTTPClient overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
HTTPClient.HTTPResponse