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.
※After Read completes successfully, the header is entirely received, so these functions will return results immediately.
※If Read returns an error, that indicates a failure to receive the HTTP response itself. 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 the version of Read that includes a timeout, this function does not time out. In other words, control will not return from this function until processing has ended. In environments where communications are slow you can expect a long time to pass before processing ends and control returns from this function. (Processing ends either when the HTTP response is fully received or the buffer is full.)
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