nn::http::Connection::Read Member Functionnn::Result Read( u8 * pBodyBuf, size_t bufLen );
| Name | Description | |
|---|---|---|
| out | pBodyBuf | Buffer storing the HTTP response message body. |
| in | bufLen | Size of pBodyBuf. |
Result values listed below. | Value | Description |
|---|---|
ResultSuccess |
Process was successful. |
| ResultBodyBufShortage | Result indicating that the message body is bigger than the buffer and cannot be fully read. |
| ResultSocketKeepAliveDisconnected | Error indicating that the server disconnected the keep-alive connection. The HTTP library usually reconnects automatically when the server disconnects a keep-alive connection, but if set to the SetLazyPostDataSetting mode, the HTTP library does not automatically reconnect to resend POST data and instead returns this error. To reconnect, first call the Connection object's Finalize function, and then call Initialize again. |
| ResultRequestHeaderErr | Error indicating that an invalid HTTP header was received. |
| ResultSocketSendErr | Error indicating failure to send socket data. This could be because the server disconnected. To reconnect, first call the Connection object's Finalize function, and then call Initialize again. |
| ResultSocketReceiveErr | Error indicating failure to receive socket data. This could be because the server disconnected. To reconnect, first call the Connection object's Finalize function, and then call Initialize again. |
| ResultSocketConnectErr | Error indicating failure to connect to socket. This could be because the server does not exist or is not running. To reconnect, first call the Connection object's Finalize function, and then call Initialize again. |
| ResultDnsResolutionErr | Error indicating that name resolution failed for the host name specified in the URL. |
| ResultConnectionCanceledErr | Error indicating that the connection was canceled. To reconnect, first call the Connection object's Finalize function, and then call Initialize again. |
| ResultInvalidParamErr | Error indicating an invalid parameter. Specify valid values for all parameters and call this function again. |
| ResultNotConnectedErr | Error indicating that no target URL was assigned to the Connection object. No action performed because the Connection object has not been initialized by a successful call of Initialize. |
| ResultNotInitializedErr | Error indicating that the library is not initialized. None of this library's functions can be used until you first call nn::http::Initialize. |
| A value other than the above. | Unexpected error (See http_Result.h for details). |
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, this indicates a failure to receive the HTTP response itself.
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 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.)
CONFIDENTIAL