Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ns_conngettype(3aolserv) [debian man page]

Ns_ConnType(3aolserver) 				   AOLserver Library Procedures 				   Ns_ConnType(3aolserver)

__________________________________________________________________________________________________________________________________________________

NAME
Ns_ConnGetType, Ns_ConnSetType - Routines to manage the HTTP response type SYNOPSIS
#include "ns.h" char * Ns_ConnGetType(conn) void Ns_ConnSetType(conn, type) ARGUMENTS
Ns_Conn conn (in) Pointer to open connection. char *type (in) Character string with response mimetype. _________________________________________________________________ DESCRIPTION
These routines both manage the eventual content-type header which is generated by a later call to Ns_ConnFlush or Ns_ConnFlushDirect as well as manage the appropriate character encoding for text output types. char *Ns_ConnGetType(conn) Return the current HTTP mime type (e.g., "text/html; charset=iso-8859-1") or NULL if no type has yet been set. void Ns_ConnSetType(conn, type) Sets the mimetype of the response to the given type. A later call to Ns_ConnFlush will include a header of the form content-type: type when generating the response. CHARSETS AND ENCODINGS
For text types, a call to Ns_ConnSetType can also include an optional "charset=" attribute. If no charset is specified, the server will append a default charset if specified as the outputcharset server configuration variable. With a given or automatically appended charset for text types, the server will then set the output encoding to the cooresponding Tcl_Encod- ing, for example, mapping the charset "iso-8859-1" to the Tcl_Encoding equivalent "iso8859-1". All text later sent via Ns_ConnFlush will be first encoded using the determined Tcl_Encoding (calls to Ns_ConnFlushDirect will bypass this encoding step). See the man pages on Ns_GetCharsetEncoding for details on how these mappings are configured. The charset modification feature was added in later versions of AOLserver to support legacy code which may have been sprinkled with direct calls to set text types without specifying the charset, e.g., calls such as: ns_return 200 text/html "<body>hello</body>" EXAMPLES
The following example demonstrates sending Japanese character data. In this case, assume "utf8string" contains a series of UTF-8 bytes with various Japanese characters. The call to Ns_ConnSetType will setup the appropriate "shiftjis" output Tcl_Encoding to match the given "shift_jis" charset: Ns_ConnSetStatus(conn, 200); Ns_ConnSetType(conn, "text/html; charset=shift_jis"); Ns_ConnFlushDirect(conn, utf8string, -1, 0); The following demonstrates the behavior of the default server charset encoding. Assume the following is set in the config file: ns_section ns/server/serverName ns_param outputcharset iso-8859-1 In this case, a call to Ns_ConnSetType(conn, "text/html") without a specific charset would be modified to include "charset=iso-8859-1". Based on this modification, the output encoding would be set to the "iso8859-1" Tcl_Encoding. SEE ALSO
Ns_ConnGetType(3), Ns_ConnSetType(3), Ns_ConnFlush(3), Ns_ConnFlushDirect(3), Ns_ConnSetRequiredHeaders(3), Ns_ConnQueueHeaders(3), Ns_GetCharsetEncoding(3), Ns_GetTypeEncoding(3), ns_conn(n) KEYWORDS
connectionn, response, status, encoding, charset AOLserver 4.0 Ns_ConnType(3aolserver)

Check Out this Related Man Page

Ns_ConnReturnData(3aolserver)				   AOLserver Library Procedures 			     Ns_ConnReturnData(3aolserver)

__________________________________________________________________________________________________________________________________________________

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 AOLserver 4.0 Ns_ConnReturnData(3aolserver)
Man Page