Other Alias
Ns_ConnCondSetHeaders, Ns_ConnSetExpiresHeader, Ns_ConnSetLastModifiedHeader, Ns_ConnSetLengthHeader, Ns_ConnSetRequiredHeadersSYNOPSIS
#include "ns.h"
void
Ns_ConnCondSetHeaders(conn, key, value)
void
Ns_ConnSetExpiresHeader(conn, expires)
void
Ns_ConnSetHeaders(conn, key, value)
void
Ns_ConnSetLastModifiedHeader(conn, mtime)
void
Ns_ConnSetLengthHeader(conn, length)
void
Ns_ConnSetRequiredHeaders(conn, type, length)
void
Ns_ConnSetTypeHeader(conn, type)
ARGUMENTS
-
Ns_Conn conn (in)
Pointer to open connection. -
char *expires (in)
Pointer to string to construct an expires header. -
char *key (in)
Pointer to string key for a header. -
int length (in)
Integer length of output content to construct a content-length header. -
time_t mtime (in)
Modification time stamp to construct a last-modified header. -
int status (in)
HTTP result status code. -
char *type (in)
Pointer to mimetype string to construct a content-type header. -
char *value (in)
Pointer to a string value for a header.
DESCRIPTION
These functions manage the output headers eventually sent through the given open connection to a client. They operate by modifying the outputheaders Ns_Set of the connection Ns_Conn structure. Headers can be modified until they are queued or sent directly via the Ns_ConnQueueHeaders or Ns_ConnFlushHeaders routines. It is possible to modify the outputheaders directly although use of these functions is preferred for consistancy.
Note that higher level output routines such as Ns_ConnFlush or the various Ns_ConnReturn routines normally generate all the headers necessary for a given response. These routines are normally only necessary for specialized applications which output additional specific headers or specialized request procedures which do not use the higher level output routines.
- void Ns_ConnCondSetHeaders(conn, key, value)
-
Append an output header of the form key: value only if the
header does not already exist in the outputheaders set.
- void Ns_ConnSetExpiresHeader(conn, expires)
-
This routine is equivalent to Ns_ConnSetHeaders(conn,
"Expires", expires). Note that the exires parameter is
treated as a string, not a timestamp. A timestamp can be constructed
with the Ns_HttpTime routine.
- void Ns_ConnSetHeaders(conn, key, value)
-
Append a header of the form key: value to the outputheaders.
This routine will append a new, possibly duplicate, header regardless
of whether a matching header already exists in the outputheaders.
- void Ns_ConnSetLastModifiedHeader(conn, mtime)
-
This routine appends a last-modified header if one does not
already exists, formatting the given modification time as a proper
HTTP timestamp with the Ns_HttpTime routine.
- void Ns_ConnSetLengthHeader(conn, length)
-
This routine appends a content-length: length header, formatting
the given integer length as a string. This routine will also record
the response length internally in the conn structure so that
it can be later retrieved via the Ns_ConnResponseLength
routine, for example, as part of a post-connection logging callback.
- void Ns_ConnSetRequiredHeaders(conn, type, length)
-
This routine appends the basic headers normally required for a
proper HTTP transaction. These include mime-version, date,
and server as well as the content-type: type and
content-length: length headers for the given arguments. If
type is NULL or length is less than zero, the corresponding
headers will not be appended. This routine is often the only header
construction routine necessary for request procedures which construct
headers manually instead of calling routines such as Ns_ConnFlush
which handle header construction and queueing automatically.
- void Ns_ConnSetTypeHeader(conn, type)
-
This routine is equivalent to Ns_ConnSetHeaders(conn,
"content-type", type).
KEYWORDS
headers, response