From 390c05b056fd61ab8374b05bc5c310c549659250 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Mon, 12 Dec 2011 18:24:46 +0100 Subject: [PATCH] Break inheritance from WGI_RESPONSE, since it is not flexible for future improvement. --- library/server/wsf/src/wsf_response.e | 46 ++++++++++++++++----------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/library/server/wsf/src/wsf_response.e b/library/server/wsf/src/wsf_response.e index 4f095437..b722c68a 100644 --- a/library/server/wsf/src/wsf_response.e +++ b/library/server/wsf/src/wsf_response.e @@ -8,9 +8,6 @@ note class WSF_RESPONSE -inherit - WGI_RESPONSE - create {WSF_SERVICE} make_from_wgi @@ -58,8 +55,14 @@ feature -- Status setting set_status_code (a_code: INTEGER) -- Set response status code -- Should be done before sending any data back to the client + require + status_not_set: not status_is_set + header_not_committed: not header_committed do wgi_response.set_status_code (a_code) + ensure + status_code_set: status_code = a_code + status_set: status_is_set end status_code: INTEGER @@ -68,20 +71,27 @@ feature -- Status setting Result := wgi_response.status_code end -feature {WGI_RESPONSE} -- Core output operation - - write (s: READABLE_STRING_8) - -- Send the string `s' - -- this can be used for header and body - do - wgi_response.write (s) - end +--feature {WGI_RESPONSE} -- Core output operation +-- +-- write (s: READABLE_STRING_8) +-- -- Send the string `s' +-- -- this can be used for header and body +-- do +-- wgi_response.write (s) +-- end feature -- Header output operation write_header_text (a_headers: READABLE_STRING_8) + require + status_set: status_is_set + header_not_committed: not header_committed do wgi_response.write_header_text (a_headers) + ensure + status_set: status_is_set + header_committed: header_committed + message_writable: message_writable end write_header (a_status_code: INTEGER; a_headers: detachable ARRAY [TUPLE [key: READABLE_STRING_8; value: READABLE_STRING_8]]) @@ -122,12 +132,16 @@ feature -- Output operation write_string (s: READABLE_STRING_8) -- Send the string `s' + require + message_writable: message_writable do wgi_response.write_string (s) end write_substring (s: READABLE_STRING_8; a_begin_index, a_end_index: INTEGER) -- Send the substring `s[a_begin_index:a_end_index]' + require + message_writable: message_writable do wgi_response.write_substring (s, a_begin_index, a_end_index) end @@ -137,6 +151,8 @@ feature -- Output operation -- If s is Void, this means this was the final chunk -- Note: that you should have header -- "Transfer-Encoding: chunked" + require + message_writable: message_writable local hex: STRING i: INTEGER @@ -208,14 +224,6 @@ feature -- Redirect redirect_now_with_custom_status_code (a_url, {HTTP_STATUS_CODE}.moved_permanently) end -feature {WGI_RESPONSE, WGI_SERVICE} -- Commit - - commit - -- Commit the current response - do - wgi_response.commit - end - note copyright: "2011-2011, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"