indexing
	description: "Class which deals with the output header"
	date: "$Date$"
	revision: "$Revision$"

class interface
	CGI_RESPONSE_HEADER

feature -- Access

	Document_moved_status: INTEGER is 301
			-- (from CGI_COMMON_STATUS_TYPES)

	Forbidden_status: INTEGER is 403
			-- (from CGI_COMMON_STATUS_TYPES)

	header: STRING
			-- Message Header which will be returned to the
			-- the browser.

	Internal_server_error_status: INTEGER is 500
			-- (from CGI_COMMON_STATUS_TYPES)

	is_complete_header: BOOLEAN
			-- Is Current header a complete header ?

	is_sent: BOOLEAN
			-- Is current header sent to the browser ?

	No_response_status: INTEGER is 204
			-- (from CGI_COMMON_STATUS_TYPES)

	Not_found_status: INTEGER is 404
			-- (from CGI_COMMON_STATUS_TYPES)

	Not_implemented_status: INTEGER is 501
			-- (from CGI_COMMON_STATUS_TYPES)

	output: STDOUT
			-- Shared standard output.
			-- (from CGI_IN_AND_OUT)

	response_header: CGI_RESPONSE_HEADER
			-- (from CGI_IN_AND_OUT)

	stdin: STDIN
			-- Shared standard input
			-- (from CGI_IN_AND_OUT)

	Success_status: INTEGER is 200
			-- (from CGI_COMMON_STATUS_TYPES)

	Unauthorized_status: INTEGER is 401
			-- (from CGI_COMMON_STATUS_TYPES)
	
feature -- Advanced Settings

	set_cookie (key, value, expiration, path, domain, secure: STRING)
			-- Set a cookie on the client's machine
			-- with key 'key' and value 'value'.
		require
			not_yet_sent: not is_sent
			make_sense: (key /= void and value /= void) and then (not key.is_empty and not value.is_empty)
			header_exists: header /= void
			header_is_complete: is_complete_header

	set_expiration (a_date: STRING)
			-- Set the expiration date before which the page needs to be
			-- refreshed
		require
			not_yet_sent: not is_sent
			date_exists: a_date /= void
			header_exists: header /= void
			header_is_complete: is_complete_header

	set_pragma (a_pragma: STRING)
			-- Set the pragma which indicates whether
			-- the page accepts to be cached
			-- or not. An example of pragam is "no-cache"
		require
			not_yet_sent: not is_sent
			pragma_exists: a_pragma /= void
			header_exists: header /= void
			header_is_complete: is_complete_header
	
feature -- Basic Operations

	generate_http_redirection (an_url: STRING; is_secure: BOOLEAN)
			-- Generate CGI secure re-direction, via 'https' protocol if secure,
			--	via http if not.
		require
			not_yet_sent: not is_sent
			url_not_void_and_not_empty: an_url /= void and then not an_url.is_empty
			header_void: header = void

	generate_text_header
			-- Generate header for a future text (generally HTML)
			-- you are going to send.
		require
			header_void: header = void
			not_yet_sent: not is_sent

	reinitialize_header
			-- Re-initialize header.
			-- May be called if the header built sor far
			-- has to be re-build from scratch.
		require
			not_yet_sent: not is_sent
		ensure
			reinitialized: header = void and not is_complete_header and not is_sent

	return_status (a_status: INTEGER; a_message: STRING)
			-- Set the status of the user request.
			-- A complete list of status may be found at :
			-- http://www.w3.org/hypertext/WWW/protocols/HTTP/HTRESP.html
			-- See also CGI_COMMON_STATUS_TYPES
		require
			not_yet_sent: not is_sent
			message_exists: a_message /= void
			header_void: header /= void

	send_to_browser
			-- Send the header to browser.
			-- This operation has to be performed before
			-- you send anything else to the browser.
		require
			header_exists: header /= void
			not_yet_sent: not is_sent
		ensure
			header_sent: is_sent
	
invariant

		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

end -- class CGI_RESPONSE_HEADER