Provided by: aolserver4-dev_4.5.1-16_amd64
NAME
Ns_ConnQueueHeaders, Ns_ConnFlushHeaders - Routines to construct send HTTP response headers
SYNOPSIS
#include "ns.h" void Ns_ConnFlushHeaders(conn, status) void Ns_ConnQueueHeaders(conn, status)
ARGUMENTS
Ns_Conn conn (in) Pointer to open connection. int status (in) HTTP response status. _________________________________________________________________
DESCRIPTION
These function format headers pending in the outputheaders Ns_Set of the given conn Ns_Conn structure to be sent to the client. The headers data along with a preceedin0fRTto response line with the0fRvsepsatraattuosrscbetweengheaderTkey:1value pairs and aftrailing as a single string with indicate end of headers. int Ns_ConnFlushHeaders(conn) This routine constructs the headers and then attempts to send them immediately to the client. The result is either NS_OK if the content was sent, NS_ERROR otherwise. void Ns_ConnQueueHeaders(conn) This routine constructs the headers as with Ns_ConnFlushHeaders but does not send the data to the client. Instead, the resulting headers string is stored in an internal buffer to be sent later on the first call to Ns_ConnSend. Delaying the flush of the content helps increase performance by providing the opportunity to combine the headers and content responses into a single system call. Note that higher level routines which generate complete responses such as the Ns_ConnReturn routines or Ns_ConnFlush call Ns_ConnQueueHeaders automatically as needed. Only custom code which constructs headers manually and sends content directly must include a call to Ns_ConnQueueHeaders or Ns_ConnFlushHeaders before generating the output content.
EXAMPLES
The following example demonstrates a simple response. In this case, the headers are queued and sent with the small "hello" message on the call to Ns_ConnPuts which internally calls Ns_ConnSend: Ns_ConnSetRequiredHeaders(conn, "text/plain", 5); Ns_ConnQueueHeaders(conn, 200); Ns_ConnPuts(conn, "hello");
SEE ALSO
Ns_ConnSetHeaders(3), Ns_ConnSend(3)
KEYWORDS
connection, headers