Represents either an incoming or outgoing response to a HTTP request. More...
#include <HttpResponse.h>
Public Member Functions | |
| ~HttpResponse () | |
| bool | sendString (const String &text) |
| bool | sendString (String &&text) noexcept |
| HttpResponse * | setContentType (const String &type) |
| HttpResponse * | setContentType (enum MimeType type) |
| HttpResponse * | setCookie (const String &name, const String &value, bool append=false) |
| HttpResponse * | setHeader (const String &name, const String &value) |
| HttpResponse * | setCache (int maxAgeSeconds=3600, bool isPublic=false) |
| HttpResponse * | setAllowCrossDomainOrigin (const String &controlAllowOrigin) |
| bool | sendFile (const String &fileName, bool allowGzipFileCheck=true) |
| Send file by name. More... | |
| bool | sendNamedStream (IDataSourceStream *newDataStream) |
| Parse and send stream, using the name to determine the content type. More... | |
| bool | sendDataStream (IDataSourceStream *newDataStream, enum MimeType type) |
| Send data from the given stream object. More... | |
| bool | sendDataStream (IDataSourceStream *newDataStream, const String &reqContentType=nullptr) |
| Send data from the given stream object. More... | |
| String | getBody () |
| Moves content from the body stream into a String. More... | |
| void | reset () |
| reset response so it can be re-used More... | |
| void | setBuffer (ReadWriteStream *buffer) |
| Called by connection to specify where incoming response data is written. More... | |
| void | freeStreams () |
| release allocated stream memory More... | |
| bool | isSuccess () |
| Determine if the response status indicates success. More... | |
| String | toString () const |
| Tries to present a readable version of the current response values. More... | |
Public Attributes | |
| HttpStatus | code = HTTP_STATUS_OK |
| The HTTP status response code. More... | |
| HttpHeaders | headers |
| Response headers. More... | |
| ReadWriteStream * | buffer = nullptr |
| Internal stream for storing strings and receiving responses. More... | |
| IDataSourceStream * | stream = nullptr |
| The body stream. More... | |
Detailed Description
Represents either an incoming or outgoing response to a HTTP request.
Constructor & Destructor Documentation
◆ ~HttpResponse()
|
inline |
Member Function Documentation
◆ freeStreams()
| void HttpResponse::freeStreams | ( | ) |
release allocated stream memory
◆ getBody()
|
inline |
Moves content from the body stream into a String.
- Return values
-
String
- Note
- Move semantics are used to ensure that no/minimal additional memory is required. If your application has set a non-memory stream type then the method will fail and return an invalid String. The stream content will be left unchanged.
◆ isSuccess()
|
inline |
Determine if the response status indicates success.
◆ reset()
| void HttpResponse::reset | ( | ) |
reset response so it can be re-used
◆ sendDataStream() [1/2]
| bool HttpResponse::sendDataStream | ( | IDataSourceStream * | newDataStream, |
| const String & | reqContentType = nullptr |
||
| ) |
Send data from the given stream object.
- Parameters
-
newDataStream reqContentType
- Return values
-
on error returns false and stream will have been destroyed so any external references to it must be invalidated.
- Note
- all data is submitted via stream so called by internal routines
◆ sendDataStream() [2/2]
|
inline |
Send data from the given stream object.
- Parameters
-
newDataStream type
- Return values
-
false on error
◆ sendFile()
Send file by name.
- Parameters
-
fileName allowGzipFileCheck If true, check file extension to see if content compressed
- Return values
-
bool
◆ sendNamedStream()
| bool HttpResponse::sendNamedStream | ( | IDataSourceStream * | newDataStream | ) |
Parse and send stream, using the name to determine the content type.
- Parameters
-
newDataStream If not set already, the contentType will be obtained from the name of this stream
- Return values
-
bool
◆ sendString() [1/2]
◆ sendString() [2/2]
◆ setAllowCrossDomainOrigin()
|
inline |
◆ setBuffer()
| void HttpResponse::setBuffer | ( | ReadWriteStream * | buffer | ) |
Called by connection to specify where incoming response data is written.
- Parameters
-
buffer
◆ setCache()
| HttpResponse* HttpResponse::setCache | ( | int | maxAgeSeconds = 3600, |
| bool | isPublic = false |
||
| ) |
◆ setContentType() [1/2]
|
inline |
◆ setContentType() [2/2]
|
inline |
◆ setCookie()
| HttpResponse* HttpResponse::setCookie | ( | const String & | name, |
| const String & | value, | ||
| bool | append = false |
||
| ) |
◆ setHeader()
|
inline |
◆ toString()
| String HttpResponse::toString | ( | ) | const |
Tries to present a readable version of the current response values.
- Return values
-
String
Member Data Documentation
◆ buffer
| ReadWriteStream* HttpResponse::buffer = nullptr |
Internal stream for storing strings and receiving responses.
◆ code
| HttpStatus HttpResponse::code = HTTP_STATUS_OK |
The HTTP status response code.
◆ headers
| HttpHeaders HttpResponse::headers |
Response headers.
◆ stream
| IDataSourceStream* HttpResponse::stream = nullptr |
The body stream.
The documentation for this class was generated from the following file:
1.8.17