nn::http::Connection::Read Member Function

Syntax

nn::Result Read(
     u8 * pBodyBuf,
     size_t bufLen
);

Arguments

Name Description
out pBodyBuf Buffer storing the HTTP response message body.
in bufLen Size of pBodyBuf.

Return Values

Returns the result of the operation.

Description

Reads an HTTP response.

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.
Note:If Read completes successfully, the entire header has been received and these functions return immediately.
Note: If Read returns an error, receiving the HTTP response failed.
The Read return value even indicates success, therefore, if the receive operation succeeded and a message indicates a communication error (authentication failure or similar).
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.

Revision History

2010/06/14
Initial version.

CONFIDENTIAL