Now WGI_RESPONSE.set_status_code (..) has a new argument to pass optional custom reason phrase.

This is a minor breaking change (but prior to the first release, so acceptable)
   And then it is now possible to precise a custom reason phrase (useful for 4xx and 5xx response)

At the WSF_RESPONSE level, the status code is now sent only when the header are sent.
thus, it is possible to change the status code as long as no header is sent.
(in the future, we should also try to delay the sending of headers)

Removed WGI_RESPONSE.put_header_lines (..) which was not used, and WGI is not meant to provide such user friendly features
Now this is available directly on WSF_RESPONSE
This commit is contained in:
Jocelyn Fiat
2012-04-12 11:19:41 +02:00
parent 082def2b70
commit b541efcc8f
14 changed files with 149 additions and 70 deletions

View File

@@ -48,7 +48,7 @@ feature -- Execution
if attached (create {EXCEPTION_MANAGER}).last_exception as e and then attached e.exception_trace as l_trace then
if res /= Void then
if not res.status_is_set then
res.set_status_code ({HTTP_STATUS_CODE}.internal_server_error)
res.set_status_code ({HTTP_STATUS_CODE}.internal_server_error, Void)
end
if res.message_writable then
res.put_string ("<pre>" + l_trace + "</pre>")

View File

@@ -36,21 +36,24 @@ feature {NONE} -- Initialization
feature -- Status writing
put_status_line (a_code: INTEGER)
-- Put status code line for `a_code'
--| Note this is a default implementation, and could be redefined
--| for instance in relation to NPH CGI script
put_status_line (a_code: INTEGER; a_reason_phrase: detachable READABLE_STRING_8)
-- <Precursor>
local
s: STRING
m: detachable READABLE_STRING_8
do
if a_code /= 200 then
create s.make (16)
s.append ("Status:")
s.append_character (' ')
s.append_integer (a_code)
if attached http_status_code_message (a_code) as l_status_message then
m := a_reason_phrase
if m = Void then
m := http_status_code_message (a_code)
end
if m /= Void then
s.append_character (' ')
s.append_string (l_status_message)
s.append_string (m)
end
put_header_line (s)
end