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:
@@ -49,15 +49,17 @@ feature -- Status setting
|
||||
deferred
|
||||
end
|
||||
|
||||
set_status_code (a_code: INTEGER)
|
||||
-- Set response status code
|
||||
set_status_code (a_code: INTEGER; a_reason_phrase: detachable READABLE_STRING_8)
|
||||
-- Set response status code with custom `a_reason_phrase' if precised
|
||||
-- Should be done before sending any data back to the client
|
||||
require
|
||||
a_code_positive: a_code > 0
|
||||
status_not_set: not status_committed
|
||||
header_not_committed: not header_committed
|
||||
deferred
|
||||
ensure
|
||||
status_code_set: status_code = a_code
|
||||
status_reason_phrase_set: status_reason_phrase = a_reason_phrase
|
||||
status_set: status_is_set
|
||||
end
|
||||
|
||||
@@ -66,6 +68,13 @@ feature -- Status setting
|
||||
deferred
|
||||
end
|
||||
|
||||
status_reason_phrase: detachable READABLE_STRING_8
|
||||
-- Custom status reason phrase for the Response (optional)
|
||||
deferred
|
||||
ensure
|
||||
Result /= Void implies status_is_set
|
||||
end
|
||||
|
||||
feature -- Header output operation
|
||||
|
||||
put_header_text (a_text: READABLE_STRING_8)
|
||||
@@ -79,17 +88,7 @@ feature -- Header output operation
|
||||
deferred
|
||||
ensure
|
||||
status_set: status_is_set
|
||||
header_committed: header_committed
|
||||
message_writable: message_writable
|
||||
end
|
||||
|
||||
put_header_lines (a_lines: ITERABLE [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])
|
||||
require
|
||||
status_set: status_is_set
|
||||
header_not_committed: not header_committed
|
||||
deferred
|
||||
ensure
|
||||
status_set: status_is_set
|
||||
status_committed: status_committed
|
||||
header_committed: header_committed
|
||||
message_writable: message_writable
|
||||
end
|
||||
|
||||
@@ -62,10 +62,13 @@ feature -- Specific output
|
||||
|
||||
feature -- Status writing
|
||||
|
||||
put_status_line (a_code: INTEGER)
|
||||
put_status_line (a_code: INTEGER; a_reason_phrase: detachable READABLE_STRING_8)
|
||||
-- Put status code line for `a_code'
|
||||
-- with custom `a_reason_phrase' if precised
|
||||
--| Note this is a default implementation, and could be redefined
|
||||
--| for instance in relation to NPH CGI script
|
||||
require
|
||||
a_code_positive: a_code > 0
|
||||
deferred
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user