|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectHTTPClient.Response
This class represents an intermediate response. It's used internally by the modules. When all modules have handled the response then the HTTPResponse fills in its fields with the data from this class.
| Field Summary | |
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 |
(package private) int |
cd_type
this indicates how the length of the entity body is determined |
(package private) int |
ContentLength
the message length of the response if either there is no data (in which case ContentLength=0) or if the message length is controlled by a Content-Length header. |
(package private) byte[] |
Data
the data (body) returned. |
(package private) URI |
EffectiveURI
the final URI of the document. |
(package private) boolean |
final_resp
should this response be handled further? |
(package private) boolean |
got_headers
signals if we have got and parsed the headers yet |
(package private) boolean |
got_trailers
signals if we have got and parsed the trailers yet |
(package 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
|
(package private) HTTPResponse |
http_resp
the HTTPResponse we're coupled with |
static int |
HTTPS
|
InputStream |
inp_stream
our input stream (usually from the stream demux). |
(package private) boolean |
isFirstResponse
|
(package private) boolean |
reading_headers
signals if we in the process of reading the headers |
(package private) String |
ReasonLine
the reason line associated with the status code. |
(package private) Request |
req
|
(package private) String |
resource
the resource in the request (for debugging purposes) |
(package private) boolean |
retry
should the request be retried by the application? |
static int |
SHTTP
|
(package private) int |
StatusCode
the status code returned. |
(package private) int |
timeout
the timeout for read operations |
(package private) CIHashtable |
Trailers
any trailers which were received and do not fit in the above list. |
(package private) boolean |
trailers_read
|
(package private) String |
Version
the HTTP version of the response. |
| Constructor Summary | |
(package private) |
Response(Request request,
boolean used_proxy,
StreamDemultiplexor stream_handler)
Creates a new Response and registers it with the stream-demultiplexor. |
(package private) |
Response(Request request,
InputStream is)
Creates a new Response that reads from the given stream. |
|
Response(String version,
int status,
String reason,
NVPair[] headers,
byte[] data,
InputStream is,
int cont_len)
Create a new response with the given info. |
| Method Summary | |
Object |
clone()
|
void |
deleteHeader(String header)
Removes a header field from the list of headers. |
void |
deleteTrailer(String trailer)
Removes a trailer field from the list of trailers. |
(package private) int |
getContinue()
Wait for either a '100 Continue' or an error. |
byte[] |
getData()
Reads all the response data into a byte array. |
URI |
getEffectiveURI()
get the final URI of the document. |
URL |
getEffectiveURL()
Deprecated. use getEffectiveURI() instead |
String |
getHeader(String hdr)
retrieves the field for a given header. |
Date |
getHeaderAsDate(String hdr)
retrieves the field for a given header. |
int |
getHeaderAsInt(String hdr)
retrieves the field for a given header. |
InputStream |
getInputStream()
Gets an input stream from which the returned data can be read. |
String |
getReasonLine()
give the reason line associated with the status code. |
int |
getStatusCode()
give the status code for this request. |
String |
getTrailer(String trailer)
Retrieves the field for a given trailer. |
Date |
getTrailerAsDate(String trailer)
Retrieves the field for a given trailer. |
int |
getTrailerAsInt(String trailer)
Retrieves the field for a given tailer. |
String |
getVersion()
get the HTTP version used for the response. |
boolean |
hasEntity()
Some responses such as those from a HEAD or with certain status codes don't have an entity. |
(package private) void |
markAsFirstResponse(Request req)
This marks this response as belonging to the first request made over an HTTPConnection. |
(package private) void |
readTrailers(InputStream inp)
This is called by the StreamDemultiplexor to read all the trailers of a chunked encoded entity. |
boolean |
retryRequest()
|
void |
setEffectiveURI(URI final_uri)
set the final URI of the document. |
void |
setEffectiveURL(URL final_url)
Deprecated. use setEffectiveURI() instead |
void |
setHeader(String header,
String value)
Set a header field in the list of headers. |
void |
setRetryRequest(boolean flag)
Should the request be retried by the application? This can be used by modules to signal to the application that it should retry the request. |
void |
setTrailer(String trailer,
String value)
Set a trailer field in the list of trailers. |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
HTTPResponse http_resp
int timeout
public InputStream inp_stream
String resource
int StatusCode
String ReasonLine
String Version
URI EffectiveURI
CIHashtable Headers
CIHashtable Trailers
int ContentLength
int cd_type
byte[] Data
boolean reading_headers
boolean got_headers
boolean got_trailers
boolean final_resp
boolean retry
boolean trailers_read
Request req
boolean isFirstResponse
public static final int HTTP
public static final int HTTPS
public static final int SHTTP
public static final int HTTP_NG
public static final int HTTP_1_0
public static final int HTTP_1_1
public static final int CD_NONE
public static final int CD_HDRS
public static final int CD_0
public static final int CD_CLOSE
public static final int CD_CONTLEN
public static final int CD_CHUNKED
public static final int CD_MP_BR
| Constructor Detail |
Response(Request request,
boolean used_proxy,
StreamDemultiplexor stream_handler)
throws IOException
Response(Request request,
InputStream is)
throws IOException
request - the subrequestis - the input stream from which to read the headers and
data.
public Response(String version,
int status,
String reason,
NVPair[] headers,
byte[] data,
InputStream is,
int cont_len)
If data is not null then that is used; else if the is is not null that is used; else the entity is empty. If the input stream is used then cont_len specifies the length of the data that can be read from it, or -1 if unknown.
version - the response version (such as "HTTP/1.1")status - the status codereason - the reason lineheaders - the response headersdata - the response entityis - the response entity as an InputStreamcont_len - the length of the data in the InputStream| Method Detail |
public final int getStatusCode()
throws IOException
getStatusCode in interface RoResponseIOException - If any exception occurs on the socket.
public final String getReasonLine()
throws IOException
getReasonLine in interface RoResponseIOException - If any exception occurs on the socket.
public final String getVersion()
throws IOException
getVersion in interface RoResponseIOException - If any exception occurs on the socket.
int getContinue()
throws IOException
IOException
public final URI getEffectiveURI()
throws IOException
IOException - If any exception occurs on the socket.public void setEffectiveURI(URI final_uri)
public final URL getEffectiveURL()
throws IOException
IOException - If any exception occurs on the socket.getEffectiveURI()public void setEffectiveURL(URL final_url)
setEffectiveURI(HTTPClient.URI)
public String getHeader(String hdr)
throws IOException
getHeader in interface RoResponsehdr - the header name.
IOException - If any exception occurs on the socket.
public int getHeaderAsInt(String hdr)
throws IOException,
NumberFormatException
getHeaderAsInt in interface RoResponsehdr - the header name.
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.
public Date getHeaderAsDate(String hdr)
throws IOException,
IllegalArgumentException
Note: When sending dates use Util.httpDate().
getHeaderAsDate in interface RoResponsehdr - the header name.
IOException - If any exception occurs on the socket.
IllegalArgumentException - If the header cannot be parsed
as a date or time.
public void setHeader(String header,
String value)
header - The name of header field to set.value - The value to set the field to.public void deleteHeader(String header)
header - The name of header field to remove.
public String getTrailer(String trailer)
throws IOException
getData().
getTrailer in interface RoResponsetrailer - the trailer name.
IOException - If any exception occurs on the socket.
public int getTrailerAsInt(String trailer)
throws IOException,
NumberFormatException
getTrailerAsInt in interface RoResponsetrailer - the tailer name.
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.
public Date getTrailerAsDate(String trailer)
throws IOException,
IllegalArgumentException
Note: When sending dates use Util.httpDate().
getTrailerAsDate in interface RoResponsetrailer - the trailer name.
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.
public void setTrailer(String trailer,
String value)
trailer - The name of trailer field to set.value - The value to set the field to.public void deleteTrailer(String trailer)
trailer - The name of trailer field to remove.
public byte[] getData()
throws IOException
getData in interface RoResponseIOException - If any io exception occured while reading
the datagetInputStream()
public InputStream getInputStream()
throws IOException
getInputStream in interface RoResponseIOException - If any exception occurs on the socket.getData()
public boolean hasEntity()
throws IOException
IOExceptionpublic void setRetryRequest(boolean flag)
If a module sets this flag then it must also reset() the the HttpOutputStream so it may be reused by the application. It should then also use this HttpOutputStream to recognize the retried request in the requestHandler().
flag - indicates whether the application should retry the request.public boolean retryRequest()
void readTrailers(InputStream inp)
throws IOException
inp - the raw input stream to read from
IOException - if any IOException is thrown by the streamvoid markAsFirstResponse(Request req)
req - The Request sentpublic Object clone()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||