nn::http::Connection::GetHeaderField Member Function

Syntax

nn::Result GetHeaderField(
     const char * pLabel,
     char * pFieldBuf,
     size_t bufSize,
     size_t * pFieldLengthCourier = NULL
) const;

Arguments

Name Description
in pLabel Label name.
out pFieldBuf Buffer that stores the field value.
in bufSize Data size of pFieldBuf.
out pFieldLengthCourier Buffer that stores the data size of the field value. This argument can be omitted if you don't need the data size of the field value.

Return Values

Returns the function's execution result. Returns a Result listed below.
Value Description
ResultSuccess Process was successful.
ResultSocketKeepAliveDisconnected Error indicating that the server disconnected the keep-alive connection. The HTTP library usually reconnects automatically in such cases, 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 class'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 class'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 class'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 class'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 class'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 a Connection class instance for which the target URL is not assigned. The function has not done anything as it has been called on a Connection instance for which you have not yet successfully called 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).

Description

Gets the field value that matches the specified label. This field value is obtained from the message header of the HTTP response that was received.

This function blocks until the header is completely received. The receive operation completes if the following conditions are met.
・ All header data has been received.
・ The operation was cancelled.
・ A communication error occurred (for example, DNS name resolution failed).
If the header was already completely received by another function, this function will return the response immediately.


Note: If the pFieldBuf size is smaller than the field value size, as much data is stored in pFieldBuf as will fit, and the field value size is stored in pFieldLengthCourier.

Note: If pFieldBuf==NULL or bufSize==0, and if pFieldLengthCourier!=NULL, the field length is stored in pFieldLengthCourier.

Note: Unlike the version of GetHeaderField 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.

Revision History

2010/06/14
Initial version.

CONFIDENTIAL