Ns_ConnQueueHeaders, Ns_ConnFlushHeaders
Routines to construct send HTTP response headers
- Provided by: aolserver4-dev (Version: 4.5.1-18)
- Source: aolserver4
- Report a bug
Routines to construct send HTTP response headers
#include "ns.h" void Ns_ConnFlushHeaders(conn, status) void Ns_ConnQueueHeaders(conn, status)
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 preceeding HTTP response line with the given status code (e.g., "HTTP/1.1 200 OK") is formatted as a single string with 0fR separators between header key: value pairs and a trailing 0fR to indicate end of headers.
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.
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");
connection, headers