HomeForumSourceResearchGuide
Sign in to contribute to source. how it works
Type definition file ws.DocStream by barry
expand copy to clipboardexpand
uses net.Stream
uses net.http.Header

/* {"description" : "Interface to write HTTP response data to a client request, including setting session cookie state."} */

interface DocStream {
	
	/* {"@description" : "Construct a new doc stream. This is done automatically by a web framework."} */
	DocStream(store Stream s, store Header headers[], opt bool encrypted)
	
	/* {"@description" : "Get the list of request headers sent by the client."} */
	Header[] getRequestHeaders()

	/* {"@description" : "Check if the underlying network connection is encrypted (via HTTPS) or is a regular HTTP connection."} */
	bool isEncrypted()
	
	/* {"@description" : "Push a context onto the stack, collect content without sending anything."} */
	void pushContext()
	
	/* {"@description" : "Pop headers to next context on the stack."} */
	void popContext()
	
	/* {"@description" : "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()."} */
	void setSessionKey(char key[], char value[])
	
	/*
	 {"@description" : "Get a piece of session state, identified by a given key, as previously set by setSessionKey.",
		"@return" : "The value of the session state key, as previously set by setSessionKey, or null if no such key exists."}
	*/
	char[] getSessionKey(char key[])
	
	/*
	 {"@description" : "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 remSessionKey(char key[])
	
	/*
	 {"@description" : "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 setStatusCode(int code, char reason[], bool directStream)
	
	/*
	 {"@description" : "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 setHeaders(store Header headers[])
	
	/*
	 {"@description" : "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 write(char str[])
	
	/*
	 {"@description" : "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."}
	*/
	void sendResponse()
	
	/* {"@description" : "Framework function to check if anything was sent by this stream."} */
	bool responseSent()
	}
Revision history
To propose a new revision to this entity, use dana source put -ut your/new/version.dn -n ws.DocStream -m "reason for update" -u yourUsername
Version 2 by barry
Version 1 (this version) by barry
Notes for this version: Standard Library Initialisation