#include "nsd.h"Functions | |
| void | Ns_RegisterReturn (int status, char *url) |
| void | Ns_RegisterRedirect (char *server, int status, char *url) |
| void | Ns_ConnConstructHeaders (Ns_Conn *conn, Ns_DString *dsPtr) |
| void | Ns_ConnQueueHeaders (Ns_Conn *conn, int status) |
| int | Ns_ConnFlushHeaders (Ns_Conn *conn, int status) |
| void | Ns_ConnSetHeaders (Ns_Conn *conn, char *field, char *value) |
| void | Ns_ConnCondSetHeaders (Ns_Conn *conn, char *field, char *value) |
| void | Ns_ConnReplaceHeaders (Ns_Conn *conn, Ns_Set *newheaders) |
| void | Ns_ConnSetRequiredHeaders (Ns_Conn *conn, char *newtype, int length) |
| void | Ns_ConnSetTypeHeader (Ns_Conn *conn, char *type) |
| void | Ns_ConnSetLengthHeader (Ns_Conn *conn, int length) |
| void | Ns_ConnSetLastModifiedHeader (Ns_Conn *conn, time_t *mtime) |
| void | Ns_ConnSetExpiresHeader (Ns_Conn *conn, char *expires) |
| int | Ns_ConnPrintfHeader (Ns_Conn *conn, char *fmt,...) |
| int | Ns_ConnResetReturn (Ns_Conn *conn) |
| int | Ns_ConnReturnAdminNotice (Ns_Conn *conn, int status, char *title, char *notice) |
| int | Ns_ConnReturnNotice (Ns_Conn *conn, int status, char *title, char *notice) |
| int | Ns_ConnReturnData (Ns_Conn *conn, int status, char *data, int len, char *type) |
| int | Ns_ConnReturnCharData (Ns_Conn *conn, int status, char *data, int len, char *type) |
| int | Ns_ConnReturnHtml (Ns_Conn *conn, int status, char *html, int len) |
| int | Ns_ConnReturnOk (Ns_Conn *conn) |
| int | Ns_ConnReturnNoResponse (Ns_Conn *conn) |
| int | Ns_ConnReturnRedirect (Ns_Conn *conn, char *url) |
| int | Ns_ConnReturnBadRequest (Ns_Conn *conn, char *reason) |
| int | Ns_ConnReturnUnauthorized (Ns_Conn *conn) |
| int | Ns_ConnReturnForbidden (Ns_Conn *conn) |
| int | Ns_ConnReturnNotFound (Ns_Conn *conn) |
| int | Ns_ConnReturnNotModified (Ns_Conn *conn) |
| int | Ns_ConnReturnNotImplemented (Ns_Conn *conn) |
| int | Ns_ConnReturnInternalError (Ns_Conn *conn) |
| int | Ns_ConnReturnServiceUnavailable (Ns_Conn *conn) |
| int | Ns_ConnReturnStatus (Ns_Conn *conn, int status) |
| int | Ns_ConnReturnOpenChannel (Ns_Conn *conn, int status, char *type, Tcl_Channel chan, int len) |
| int | Ns_ConnReturnOpenFile (Ns_Conn *conn, int status, char *type, FILE *fp, int len) |
| int | Ns_ConnReturnOpenFd (Ns_Conn *conn, int status, char *type, int fd, int len) |
| int | Ns_ConnReturnOpenFdEx (Ns_Conn *conn, int status, char *type, int fd, off_t off, int len) |
| void Ns_ConnCondSetHeaders | ( | Ns_Conn * | conn, | |
| char * | field, | |||
| char * | value | |||
| ) |
----------------------------------------------------------------------
Ns_ConnCondSetHeaders --
Add an output header, only if it doesn't already exist.
Results: None.
Side effects: None.
----------------------------------------------------------------------
| void Ns_ConnConstructHeaders | ( | Ns_Conn * | conn, | |
| Ns_DString * | dsPtr | |||
| ) |
----------------------------------------------------------------------
Ns_ConnConstructHeaders --
Put the header of an HTTP response into the dstring.
Results: None.
Side effects: Content length and connection-keepalive headers will be added if possible.
----------------------------------------------------------------------
Construct the HTTP response status line.
Output any headers.
Set keep-alive if the driver and connection support it.
Output all headers.
| int Ns_ConnFlushHeaders | ( | Ns_Conn * | conn, | |
| int | status | |||
| ) |
----------------------------------------------------------------------
Ns_ConnFlushHeaders --
Send out a well-formed set of HTTP headers with the given status.
Results: Number of bytes written.
Side effects: See Ns_ConnQueueHeaders.
----------------------------------------------------------------------
| int Ns_ConnPrintfHeader | ( | Ns_Conn * | conn, | |
| char * | fmt, | |||
| ... | ||||
| ) |
----------------------------------------------------------------------
Ns_ConnPrintfHeader --
Write a printf-style string right to the conn.
Results: NS_OK/NS_ERROR
Side effects: Will write to the conn; you're expected to format this like a header (like "foo: bar\n").
----------------------------------------------------------------------
| void Ns_ConnQueueHeaders | ( | Ns_Conn * | conn, | |
| int | status | |||
| ) |
----------------------------------------------------------------------
Ns_ConnQueueHeaders --
Format basic headers to be sent on the connection.
Results: None.
Side effects: See Ns_ConnConstructHeaders.
----------------------------------------------------------------------
| void Ns_ConnReplaceHeaders | ( | Ns_Conn * | conn, | |
| Ns_Set * | newheaders | |||
| ) |
----------------------------------------------------------------------
Ns_ConnReplaceHeaders --
Free the existing outpheaders and set them to a copy of newheaders.
Results: None.
Side effects: None.
----------------------------------------------------------------------
| int Ns_ConnResetReturn | ( | Ns_Conn * | conn | ) |
----------------------------------------------------------------------
Ns_ConnResetReturn --
Reset the connection, clearing any queued headers, so a basic result may be sent.
Results: NS_OK if connection could be cleared, NS_ERROR if data has already been sent.
Side effects: Will truncate queued headers.
----------------------------------------------------------------------
Clear queued headers and reset status and type.
| int Ns_ConnReturnAdminNotice | ( | Ns_Conn * | conn, | |
| int | status, | |||
| char * | title, | |||
| char * | notice | |||
| ) |
----------------------------------------------------------------------
Ns_ConnReturnAdminNotice --
Return a short notice to a client to contact system administrator.
Results: See Ns_ConnReturnNotice
Side effects: See Ns_ConnReturnNotice
----------------------------------------------------------------------
| int Ns_ConnReturnBadRequest | ( | Ns_Conn * | conn, | |
| char * | reason | |||
| ) |
----------------------------------------------------------------------
Ns_ConnReturnBadRequest --
Return an 'invalid request' HTTP status line with an error message.
Results: NS_OK/NS_ERROR
Side effects: Will close connection.
----------------------------------------------------------------------
| int Ns_ConnReturnCharData | ( | Ns_Conn * | conn, | |
| int | status, | |||
| char * | data, | |||
| int | len, | |||
| char * | type | |||
| ) |
----------------------------------------------------------------------
Ns_ConnReturnCharData --
Sets required headers, dumps them, and then writes your data.
Results: NS_OK/NS_ERROR
Side effects: May set numerous headers, will close connection.
----------------------------------------------------------------------
| int Ns_ConnReturnData | ( | Ns_Conn * | conn, | |
| int | status, | |||
| char * | data, | |||
| int | len, | |||
| char * | type | |||
| ) |
----------------------------------------------------------------------
Ns_ConnReturnData --
Sets required headers, dumps them, and then writes your data.
Results: NS_OK/NS_ERROR
Side effects: May set numerous headers, will close connection.
----------------------------------------------------------------------
| int Ns_ConnReturnForbidden | ( | Ns_Conn * | conn | ) |
----------------------------------------------------------------------
Ns_ConnReturnForbidden --
Return a 403 Forbidden response.
Results: NS_OK/NS_ERROR.
Side effects: Will close the connection.
----------------------------------------------------------------------
| int Ns_ConnReturnHtml | ( | Ns_Conn * | conn, | |
| int | status, | |||
| char * | html, | |||
| int | len | |||
| ) |
----------------------------------------------------------------------
Ns_ConnReturnHtml --
Return data of type text/html to client.
Results: NS_OK/NS_ERROR
Side effects: See Ns_ConnReturnData
----------------------------------------------------------------------
| int Ns_ConnReturnInternalError | ( | Ns_Conn * | conn | ) |
----------------------------------------------------------------------
Ns_ConnReturnInternalError --
Return a 500 Internal Error response.
Results: NS_OK/NS_ERROR
Side effects: Will close the connection.
----------------------------------------------------------------------
| int Ns_ConnReturnNoResponse | ( | Ns_Conn * | conn | ) |
----------------------------------------------------------------------
Ns_ConnReturnNoResponse --
Return a status message to the client.
Results: See Ns_ReturnStatus
Side effects: See Ns_ReturnStatus
----------------------------------------------------------------------
| int Ns_ConnReturnNotFound | ( | Ns_Conn * | conn | ) |
----------------------------------------------------------------------
Ns_ConnReturnNotFound --
Return a 404 Not Found response.
Results: NS_OK/NS_ERROR
Side effects: Will close the connection.
----------------------------------------------------------------------
| int Ns_ConnReturnNotice | ( | Ns_Conn * | conn, | |
| int | status, | |||
| char * | title, | |||
| char * | notice | |||
| ) |
----------------------------------------------------------------------
Ns_ConnReturnNotice --
Return a short notice to a client.
Results: See Ns_ConnReturnHtml.
Side effects: None.
----------------------------------------------------------------------
Detailed server information at the bottom of the page.
Padding that suppresses those horrible MSIE friendly errors. NB: Because we pad inside the body we may pad more than needed.
| int Ns_ConnReturnNotImplemented | ( | Ns_Conn * | conn | ) |
----------------------------------------------------------------------
Ns_ConnReturnNotImplemented --
Return a 501 Not Implemented response.
Results: NS_OK/NS_ERROR
Side effects: Will close the connection.
----------------------------------------------------------------------
| int Ns_ConnReturnNotModified | ( | Ns_Conn * | conn | ) |
----------------------------------------------------------------------
Ns_ConnReturnNotModified --
Return a 304 Not Modified response.
Results: NS_OK/NS_ERROR
Side effects: Will close the connection.
----------------------------------------------------------------------
| int Ns_ConnReturnOk | ( | Ns_Conn * | conn | ) |
----------------------------------------------------------------------
Ns_ConnReturnOk --
Return a status message to the client.
Results: See Ns_ReturnStatus
Side effects: See Ns_ReturnStatus
----------------------------------------------------------------------
| int Ns_ConnReturnOpenChannel | ( | Ns_Conn * | conn, | |
| int | status, | |||
| char * | type, | |||
| Tcl_Channel | chan, | |||
| int | len | |||
| ) |
----------------------------------------------------------------------
Ns_ConnReturnOpenChannel --
Send an open channel out the conn.
Results: See ReturnOpen.
Side effects: See ReturnOpen.
----------------------------------------------------------------------
| int Ns_ConnReturnOpenFd | ( | Ns_Conn * | conn, | |
| int | status, | |||
| char * | type, | |||
| int | fd, | |||
| int | len | |||
| ) |
----------------------------------------------------------------------
Ns_ConnReturnOpenFd --
Send an open fd out the conn.
Results: See ReturnOpen.
Side effects: See ReturnOpen.
----------------------------------------------------------------------
| int Ns_ConnReturnOpenFdEx | ( | Ns_Conn * | conn, | |
| int | status, | |||
| char * | type, | |||
| int | fd, | |||
| off_t | off, | |||
| int | len | |||
| ) |
----------------------------------------------------------------------
Ns_ConnReturnOpenFdEx --
Send an open fd out the conn starting at given offset. The current file position is not changed.
Results: See ReturnOpen.
Side effects: See ReturnOpen.
----------------------------------------------------------------------
| int Ns_ConnReturnOpenFile | ( | Ns_Conn * | conn, | |
| int | status, | |||
| char * | type, | |||
| FILE * | fp, | |||
| int | len | |||
| ) |
----------------------------------------------------------------------
Ns_ConnReturnOpenFile --
Send an open file out the conn.
Results: See ReturnOpen.
Side effects: See ReturnOpen.
----------------------------------------------------------------------
| int Ns_ConnReturnRedirect | ( | Ns_Conn * | conn, | |
| char * | url | |||
| ) |
----------------------------------------------------------------------
Ns_ConnReturnRedirect --
Return a 302 Redirection to the client, or 204 No Content if url is null.
Results: NS_OK/NS_ERROR
Side effects: Will close connection.
----------------------------------------------------------------------
| int Ns_ConnReturnServiceUnavailable | ( | Ns_Conn * | conn | ) |
----------------------------------------------------------------------
Ns_ConnReturnServiceUnavailable --
Return a 503 Service Unavailable response.
Results: NS_OK/NS_ERROR
Side effects: Will close the connection.
----------------------------------------------------------------------
| int Ns_ConnReturnStatus | ( | Ns_Conn * | conn, | |
| int | status | |||
| ) |
----------------------------------------------------------------------
Ns_ConnReturnStatus --
Return an arbitrary status code.
Results: NS_OK/NS_ERROR
Side effects: Will close the connection.
----------------------------------------------------------------------
| int Ns_ConnReturnUnauthorized | ( | Ns_Conn * | conn | ) |
----------------------------------------------------------------------
Ns_ConnReturnUnauthorized --
Return a 401 Unauthorized response, which will prompt the user for a Basic authentication username/password.
Results: NS_OK/NS_ERROR
Side effects: Will close the connection.
----------------------------------------------------------------------
| void Ns_ConnSetExpiresHeader | ( | Ns_Conn * | conn, | |
| char * | expires | |||
| ) |
----------------------------------------------------------------------
Ns_ConnSetExpiresHeader --
Set the Expires output header.
Results: None.
Side effects: None.
----------------------------------------------------------------------
| void Ns_ConnSetHeaders | ( | Ns_Conn * | conn, | |
| char * | field, | |||
| char * | value | |||
| ) |
----------------------------------------------------------------------
Ns_ConnSetHeaders --
Add an output header.
Results: None.
Side effects: None.
----------------------------------------------------------------------
| void Ns_ConnSetLastModifiedHeader | ( | Ns_Conn * | conn, | |
| time_t * | mtime | |||
| ) |
----------------------------------------------------------------------
Ns_ConnSetLastModifiedHeader --
Set the Last-Modified output header if it isn't already set.
Results: None.
Side effects: None.
----------------------------------------------------------------------
| void Ns_ConnSetLengthHeader | ( | Ns_Conn * | conn, | |
| int | length | |||
| ) |
----------------------------------------------------------------------
Ns_ConnSetLengthHeader --
Set the Content-Length output header.
Results: None.
Side effects: None.
----------------------------------------------------------------------
| void Ns_ConnSetRequiredHeaders | ( | Ns_Conn * | conn, | |
| char * | newtype, | |||
| int | length | |||
| ) |
----------------------------------------------------------------------
Ns_ConnSetRequiredHeaders --
Set a sane set of minimal headers for any response: MIME-Version, Date, Server, Content-Type, Content-Length
Results: None.
Side effects: None.
----------------------------------------------------------------------
Set the standard mime and date headers.
Set the standard server header, prepending "NaviServer/2.0" if AOLpress support is enabled.
Set the type and/or length headers if provided. Note that a valid length is required for connection keep-alive.
| void Ns_ConnSetTypeHeader | ( | Ns_Conn * | conn, | |
| char * | type | |||
| ) |
----------------------------------------------------------------------
Ns_ConnSetTypeHeader --
Sets the Content-Type HTTP output header
Results: None.
Side effects: None.
----------------------------------------------------------------------
| void Ns_RegisterRedirect | ( | char * | server, | |
| int | status, | |||
| char * | url | |||
| ) |
| void Ns_RegisterReturn | ( | int | status, | |
| char * | url | |||
| ) |
----------------------------------------------------------------------
Ns_RegisterRedirect, Ns_RegisterReturn --
Associate a URL with a status. Rather than return the default error page for this status, a redirect will be issued to the url.
Results: None.
Side effects: A NULL url will remove a previous redirect, if any.
----------------------------------------------------------------------
| char* reason |
| int status |
1.5.1