---
name: "Ns_ConnQueueHeaders"
section: "3aolserver"
platform: "linux"
package: "aolserver4-dev"
version: "4.5.1-18.1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/Ns_ConnQueueHeaders/3aolserver"
---

# Ns\_ConnQueueHeaders(3aolserver)

Routines to construct send HTTP response headers

```

```

## 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 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.*

- *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_ConnSetHeaders/3.md), [Ns\_ConnSend(3)](/Ns_ConnSend/3.md)

## KEYWORDS

connection, headers
