nn::http::Connection::Read Member Functionnn::Result Read( u8 * pBodyBuf, size_t bufLen ); nn::Result Read( u8 * pBodyBuf, size_t bufLen, const nn::fnd::TimeSpan & timeout );
Read(u8 *, size_t)
|
Reads an HTTP response. |
Read(u8 *, size_t, const nn::fnd::TimeSpan &)
|
This version of Read has a timeout. |
Read(u8 *, size_t)The data of the message body is stored in the buffer specified in the arguments.
If the message body is larger than the buffer, the buffer stores as much of the message body as will fit in it, and an error (with Description==ER_RES_BODYBUF_SHORTAGE) is returned.
If you run the Read function again later, the library continues reading where it left off from the previous call to Read.
Once all of the message body data is received, a Result of Success is returned.
The library maintains the following data corresponding to the message body stored in the user-specified buffer. Get these data items using the corresponding functions.
・ Response status (GetStatusCode)
・ Message header (GetHeaderField/GetHeaderAll)
Note: If these functions are used before Read is run, they block until the header is completely received.
※If Read completes successfully, the entire header has been received, so these functions return immediately.
※If Read returns an error, a failure to receive the HTTP response occurred.
Thus, if reception is successful, the value returned by Read will indicate success even if a message reports a communications error (such as an authentication failure). Use the status code obtained from the GetStatusCode function to check for these other kinds of errors. Note: Unlike Read, this function does not have an attached timeout. In other words, the process will not return from this function until processing has ended.
For this reason, in environments where communications are slow you can expect a long time to pass before the process ends (an HTTP response has been received, or the buffer is full) and returns from this function.
Read(u8 *, size_t, const nn::fnd::TimeSpan &)Other than allowing the caller to specify a timeout, this version functions identically to Read. For feature details, see the function reference for the version without a timeout. Returns ResultTimeout if no HTTP response has been fully received or if the buffer has not filled within the timeout period. If ResultTimeout is returned, the connection is automatically canceled. (In other words, the function internally implements Cancel.)
CONFIDENTIAL