|
OpenTop 1.5 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | Cross-Platform C++ | ||||||
| SUMMARY: CONSTRUCTOR | METHOD | DETAIL: CONSTRUCTOR | METHOD | |||||||
#include "ot/web/HttpResponse.h"
Class to represent a response to a request sent to a HTTP server.
The HttpResponse class encapsulates all the pertinent information returned from the HTTP server including the response line and MIME-type response headers. This class may also be used to represent an interim response from an HttpClient when the application has signalled its intention to send a streamed entity as part of the HTTP request.The main difference between and interim and a final HttpResponse if that the former contains an OutputStream for the application to stream an entity to the HTTP server, whereas the latter contains the actual response from the server including a response line, MIME headers and an InputStream object when the request results in an entity being delivered to the client.
Applications can differentiate between the two kinds of HttpResponse via the isRequestInProgress() method. This returns true for interim responses and false for final responses.
An HTTP request normally involves the use of a TCP/IP socket connection to a remote server. This connection remains allocated to the application until the InputStream contained within a final response is closed or read to EndOFFile.
If the HttpResponse contains an entity which is not required by the application, and the application wishes to be able to reuse the physical network connection, then it is recommended to call discardEntity(), which will reset and free the HttpClientConnection for re-use by other requests. This action is not required if the application will read the entire entity or if no entity is returned from the HTTP server.
If the application closes the InputStream (by calling the close() method) before reaching EndOfFile, the HTTP request is terminated by physically closing the network connection. This action will obviously prevent the network connection from being re-used by subsequent requests.
| Constructor/Destructor Summary | |
HttpResponse()Default constructor. | |
HttpResponse(const HttpRequest& request)Constructor taking a HttpRequest argument. | |
| Method Summary | |
void |
clearResponseInfo()Clears the response code, response message and MIME headers. |
void |
discardEntity()Provides a means for the application to release resources associated with this HttpResponse if the contained entity (InputStream) is not required. |
const URL& |
getFinalURL() constReturns the URL representing the HTTP request that generated this HttpResponse. |
RefPtr< InputStream > |
getInputStream() constReturns an InputStream which can be used to read the entity associated with this HTTP response (if any). |
RefPtr< MimeHeaderSequence > |
getMimeHeaders() constReturns the sequence of MIME-type headers that accompany this HTTP response. |
RefPtr< OutputStream > |
getOutputStream() constReturns an OutputStream which can be used by the application to write an entity to the remote HTTP server. |
HttpProtocolVersion |
getProtocolVersion() constReturns a HttpProtocolVersion representing the version of the HTTP protocol contained within the HTTP response line. |
const String& |
getRequestMethod() constReturns the method from the HttpRequest used to generate this response. |
int |
getResponseCode() constReturns the numeric response code portion of the HTTP response line. |
const String& |
getResponseLine() constReturns the entire HTTP response line as a String. |
const String& |
getResponseMessage() constReturns the message portion of the HTTP response line. |
bool |
isRequestInProgress() constTests if this HttpResponse is an interim response for a HTTP request that is still in progress. |
void |
setFinalURL(const URL& url)Sets the URL representing the HTTP request that generated this HttpResponse. |
void |
setInputStream(InputStream* pInputStream)Sets the InputStream for this HttpResponse. |
void |
setMimeHeaders(MimeHeaderSequence* pHeaders)Sets the MimeHeaderSequence used by this HttpResponse to store the HTTP response headers. |
void |
setRequestDetails(const HttpRequest& request)Sets the method and url fields from the passed request argument. |
void |
setRequestInProgress(HttpClientConnection* pConnection, OutputStream* pOutputStream)Marks this HttpResponse as an interim response, used by the application to stream an entity to the remote HTTP server. |
void |
setRequestMethod(const String& method)Sets the request method (e.g. |
void |
setResponseLine(const String& responseLine)Sets the protocol version, response code and response message from the first response line from a HTTP server. |
| Constructor/Destructor Detail |
HttpResponse()
HttpResponse(const HttpRequest& request)
| Method Detail |
void clearResponseInfo()
void discardEntity()
const URL& getFinalURL() const
RefPtr< InputStream > getInputStream() const
RefPtr< MimeHeaderSequence > getMimeHeaders() const
RefPtr< OutputStream > getOutputStream() const
HttpProtocolVersion getProtocolVersion() const
const String& getRequestMethod() const
int getResponseCode() const
const String& getResponseLine() const
const String& getResponseMessage() const
bool isRequestInProgress() const
void setFinalURL(const URL& url)
url - void setInputStream(InputStream* pInputStream)
pInputStream - void setMimeHeaders(MimeHeaderSequence* pHeaders)
pHeaders - NullPointerException - void setRequestDetails(const HttpRequest& request)
void setRequestInProgress(HttpClientConnection* pConnection,
OutputStream* pOutputStream)
pConnection - pOutputStream - void setRequestMethod(const String& method)
method - void setResponseLine(const String& responseLine)
HTTP/v.v nnn [message]
responseLine -
|
OpenTop 1.5 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | Cross-Platform C++ | ||||||
| SUMMARY: CONSTRUCTOR | METHOD | DETAIL: CONSTRUCTOR | METHOD | |||||||