Interface DocStream
access this type via: ws.DocStream (provides, requires or uses)
Interface to write HTTP response data to a client request, including setting session cookie state.
Functions
DocStream(storeStream s, storeHeader headers[], optional bool encrypted)
Header[] getRequestHeaders()
bool isEncrypted()
void pushContext()
void popContext()
void setSessionKey(char key[], char value[])
char[] getSessionKey(char key[])
void remSessionKey(char key[])
void setStatusCode(int code, char reason[], bool directStream)
void setHeaders(storeHeader headers[])
void write(char str[])
void sendResponse()
bool responseSent()
DocStream(storeStream s, storeHeader headers[], optional bool encrypted)
Construct a new doc stream. This is done automatically by a web framework.
Header[] getRequestHeaders()
Get the list of request headers sent by the client.
bool isEncrypted()
Check if the underlying network connection is encrypted (via HTTPS) or is a regular HTTP connection.
void pushContext()
Push a context onto the stack, collect content without sending anything.
void popContext()
Pop headers to next context on the stack.
void setSessionKey(char key[], char value[])
Set a piece of session state, identified by a given key, to equal a given value. This causes a cookie to be set, so that this session state is available on subsequent web requests. This function must be called before any use of write(), setStatusCode(), or setHeaders().
char[] getSessionKey(char key[])
Get a piece of session state, identified by a given key, as previously set by setSessionKey.
returns: The value of the session state key, as previously set by setSessionKey, or null if no such key exists.
void remSessionKey(char key[])
Delete a piece of session state, identified by a given key. The deleted session state will no longer be available to subsequent web requests. This function must be called before any use of write(), setStatusCode(), or setHeaders().
void setStatusCode(int code, char reason[], bool directStream)
Set the status code that will be used for this response. This must be used before any data is sent (e.g. via write()). No data is sent as a result of this function call. If directStream is set to true, response data is sent immediately by calls to write().
void setHeaders(storeHeader headers[])
Set the response headers that will be used for this response. This must be used before any data is sent (e.g. via write()). No data is sent as a result of this function call.
void write(char str[])
Send data to the connected client. Unless directStream has been set to true via setStatusCode(), data passed to this function may be buffered into larger chunks before actually being sent to the client. By default, content is assumed to be text (HTML) and uses chunked encoding; other content types should be indicated by first using setStatusCode() / setHeaders().
void sendResponse()
In non-streaming mode, this function is called to indicate that sending of response data is complete, after which no further data can be sent in response to this request. In direct-stream mode, this function must be called before any use of write(), as its sends header information.
bool responseSent()
Framework function to check if anything was sent by this stream.