---
name: "Ns_ConnReturnHtml"
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_ConnReturnAdminNotice/3aolserver"
---

# Ns\_ConnReturnHtml(3aolserver)

Routines to generate simple single-buffer responses

Part of [Ns\_ConnReturnAdminNotice(3aolserver)](/Ns_ConnReturnAdminNotice/3aolserver.md).

```

```

## NAME

Ns\_ConnReturnAdminNotice, Ns\_ConnReturnData, Ns\_ConnReturnHtml, Ns\_ConnReturnNotice - Routines to generate simple single-buffer responses

## SYNOPSIS

```
#include "ns.h"
int
Ns_ConnReturnAdminNotice(conn, status, title, msg)

int
Ns_ConnReturnData(conn, status, data, len, type)

int
Ns_ConnReturnCharData(conn, status, data, len, type)

int
Ns_ConnReturnHtml(conn, status, msg, len)

int
Ns_ConnReturnNotice(conn, status, title, msg)
```

## ARGUMENTS

- Ns\_Conn *conn* (in)

  Pointer to open connection.

- int *status* (in)

  HTTP response status code.

- char *\*type* (in)

  Output content type.

- char *\*title* (in)

  Pointer to HTML page title string.

- int *len* (in)

  Length of content buffer.

- char *\*data* (in)

  Pointer to content buffer.

- char *\*msg* (in)

  Pointer to HTML message buffer.

  ```

  ```

## DESCRIPTION

These routines are used to generate complete responses, including headers, status codes, content types, and the requested data.  They all return a status code which is NS\_OK if the response was sent or NS\_ERROR if an underlying call to sent the content failed.

- int **Ns\_ConnReturnAdminNotice**(*conn, status, title, msg*)

  This routine is equivalent to **Ns\_ConnReturnNotice**. In prior versions, it would format a slightly different response which was later considered inconsequential.

- int **Ns\_ConnReturnData**(*conn, status, data, len, type*)

  Generates a reponse with the given HTTP *status* including a *content-type* header with the given *type*.  Content pointed to by the *data* argument of length *len* is then sent without any modification via an underlying call to **Ns\_ConnFlushDirect**.

- int **Ns\_ConnReturnCharData**(*conn, status, data, len, type*)

  Generates a response as with **Ns\_ConnReturnData** except that the given content pointed to by *data* is assumed to be a text stream which is output encoded using the appropriate Tcl\_Encoding based on the given *type* mimetype and possibly gzip compressed via an underlying call to **Ns\_ConnFlush**.

- int **Ns\_ConnReturnHtml**(*conn, status, msg, len*)

  This is equivalent to **Ns\_ConnReturnCharData**(*conn, status,* *msg, len, "text/html"*).

- int **Ns\_ConnReturnNotice**(*conn, status, title, msg*)

  Constructs a basic HTML response and sends it via **Ns\_ConnReturnHtml**. The *title* string is placed both in the \<head\> portion as well as an \<h2\> tag in the \<body\> portion of the document.  If the title is NULL, it defaults to the string "Server Message".  The *msg* string, if not NULL, follows the body and is copied unaltered.  This routine is useful for generating very basic responses.  For example, it is used by the various builtin reponse routines such as **Ns\_ConnReturnUnauthorized**.

## SEE ALSO

Ns\_ConnFlush(3), Ns\_ConnReturnFile, Ns\_ConnReturnOpenFd, Ns\_ConnReturnUnathorized.

## KEYWORDS

connnection, encoding, response
