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