Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ns_connsettype(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_ConnStatus(3aolserver)				   AOLserver Library Procedures 				 Ns_ConnStatus(3aolserver)

__________________________________________________________________________________________________________________________________________________

NAME
Ns_ConnGetStatus, Ns_ConnSetStatus - Routines to manage the HTTP response status SYNOPSIS
#include "ns.h" int Ns_ConnGetStatus(conn) void Ns_ConnSetStatus(conn, status) ARGUMENTS
Ns_Conn conn (in) Pointer to open connection. int status (in) Integer HTTP status code. _________________________________________________________________ DESCRIPTION
These routines manage the HTTP response code sent to the client in a later call to Ns_ConnFlush or Ns_ConnFlushDirect. Higher level rou- tines such as the Ns_ConnReturn functions normally call these routines automatically using standard HTTP status codes and the Ns_ConnQueue- Headers routine can be used to set the status code for lower level code which bypasses Ns_ConnFlush. int Ns_ConnGetStatus(conn) Return the current HTTP status to be sent. int Ns_ConnSetStatus(conn, status) Set the status code to be sent in the response, for example, 200 for a normal "OK" response. A later call to Ns_ConnFlush will con- struct the appropriate HTTP response including the given status with the cooresponding string status code. EXAMPLES
The following example demonstrates setting an odd status code followed by a call to Ns_ConnFlushDirect to send some data: Ns_ConnSetStatus(conn, 600); Ns_ConnSetType(conn, "text/plain"); Ns_ConnFlushDirect(conn, "hello", 5, 0); The following should provide similar results: Ns_ConnSetRequiredHeaders(conn, "text/plain", 5); Ns_ConnQueueHeaders(conn, 600); Ns_ConnPuts(conn, "hello"); Ns_ConnClose(conn); SEE ALSO
Ns_ConnGetType(3), Ns_ConnSetType(3), Ns_ConnFlush(3), Ns_ConnFlushDirect(3), Ns_ConnSetRequiredHeaders(3), Ns_ConnQueueHeaders(3), ns_conn(n) KEYWORDS
connectionn, response, status AOLserver 4.0 Ns_ConnStatus(3aolserver)
Man Page