|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--HTTPClient.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 | |
InputStream |
inp_stream
our input stream (usually from the stream demux). |
Fields inherited from interface HTTPClient.GlobalConstants |
CD_0,
CD_CHUNKED,
CD_CLOSE,
CD_CONTLEN,
CD_HDRS,
CD_MP_BR,
CD_NONE,
HTTP,
HTTP_1_0,
HTTP_1_1,
HTTP_NG,
HTTPS,
SHTTP |
Constructor Summary | |
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. |
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. |
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 |
public InputStream inp_stream
Constructor Detail |
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 InputStreamMethod Detail |
public final int getStatusCode() throws IOException
public final String getReasonLine() throws IOException
public final String getVersion() throws IOException
public final URI getEffectiveURI() throws IOException
public void setEffectiveURI(URI final_uri)
public final URL getEffectiveURL() throws IOException
getEffectiveURI()
public void setEffectiveURL(URL final_url)
setEffectiveURI(HTTPClient.URI)
public String getHeader(String hdr) throws IOException
hdr
- the header name.public int getHeaderAsInt(String hdr) throws IOException, NumberFormatException
hdr
- the header name.public Date getHeaderAsDate(String hdr) throws IOException, IllegalArgumentException
Note: When sending dates use Util.httpDate().
hdr
- the header name.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()
.trailer
- the trailer name.public int getTrailerAsInt(String trailer) throws IOException, NumberFormatException
trailer
- the tailer name.public Date getTrailerAsDate(String trailer) throws IOException, IllegalArgumentException
Note: When sending dates use Util.httpDate().
trailer
- the trailer name.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
getInputStream()
public InputStream getInputStream() throws IOException
getData()
public boolean hasEntity() throws IOException
public 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()
public Object clone()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |