From 436f2afd007eb5cd06fa03233f41e568e4d589f9 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Wed, 27 Jul 2011 18:34:06 +0200 Subject: [PATCH] Added the possibility to set the "Status" header (different from the status line) in GW_HEADER Renamed EWSGI_RESPONSE as EWSGI_RESPONSE_STREAM to avoid confusion with EWSGI_RESPONSE as stated in Paul's proposal Added default "configuration" (for nino and cgi) to be independant of the connector (at compilation time) Added example implementing Paul's proposal on top of EWSGI --- .../ewsgi/connectors/nino/nino-safe.ecf | 1 - library/server/ewsgi/connectors/nino/nino.ecf | 1 - .../default/cgi/default_ewsgi_application.e | 32 +++ .../server/ewsgi/default/ewsgi_cgi-safe.ecf | 22 ++ .../server/ewsgi/default/ewsgi_nino-safe.ecf | 26 ++ .../default/nino/default_ewsgi_application.e | 32 +++ .../nino/nino_application.e} | 4 +- .../examples/hello_world/src/hello_world.e | 2 +- .../hello_world_with_response/hello-safe.ecf | 29 +++ .../hello_world_with_response/license.lic | 10 + .../src/framework/ewsgi_response.e | 225 ++++++++++++++++++ .../framework/ewsgi_response_application.e | 57 +++++ .../src/hello_world.e | 36 +++ .../src/hello_world_response.e | 67 ++++++ .../specification/ewsgi_agent_application.e | 4 +- .../ewsgi/specification/ewsgi_application.e | 16 +- ...sgi_response.e => ewsgi_response_stream.e} | 4 +- .../src/application/gw_application_imp.e | 6 +- .../ewsgi/src/response/gw_buffered_response.e | 2 +- .../src/response/gw_in_memory_response.e | 2 +- ...esponse_imp.e => gw_response_stream_imp.e} | 6 +- library/server/ewsgi/src/support/gw_header.e | 20 ++ 22 files changed, 579 insertions(+), 25 deletions(-) create mode 100644 library/server/ewsgi/default/cgi/default_ewsgi_application.e create mode 100644 library/server/ewsgi/default/ewsgi_cgi-safe.ecf create mode 100644 library/server/ewsgi/default/ewsgi_nino-safe.ecf create mode 100644 library/server/ewsgi/default/nino/default_ewsgi_application.e rename library/server/ewsgi/{connectors/nino/src/gw_nino_application.e => default/nino/nino_application.e} (93%) create mode 100644 library/server/ewsgi/examples/hello_world_with_response/hello-safe.ecf create mode 100644 library/server/ewsgi/examples/hello_world_with_response/license.lic create mode 100644 library/server/ewsgi/examples/hello_world_with_response/src/framework/ewsgi_response.e create mode 100644 library/server/ewsgi/examples/hello_world_with_response/src/framework/ewsgi_response_application.e create mode 100644 library/server/ewsgi/examples/hello_world_with_response/src/hello_world.e create mode 100644 library/server/ewsgi/examples/hello_world_with_response/src/hello_world_response.e rename library/server/ewsgi/specification/response/{ewsgi_response.e => ewsgi_response_stream.e} (95%) rename library/server/ewsgi/src/response/{gw_response_imp.e => gw_response_stream_imp.e} (94%) diff --git a/library/server/ewsgi/connectors/nino/nino-safe.ecf b/library/server/ewsgi/connectors/nino/nino-safe.ecf index 633e055f..635aea99 100644 --- a/library/server/ewsgi/connectors/nino/nino-safe.ecf +++ b/library/server/ewsgi/connectors/nino/nino-safe.ecf @@ -11,7 +11,6 @@ - diff --git a/library/server/ewsgi/connectors/nino/nino.ecf b/library/server/ewsgi/connectors/nino/nino.ecf index 2b6d9204..c12d3562 100644 --- a/library/server/ewsgi/connectors/nino/nino.ecf +++ b/library/server/ewsgi/connectors/nino/nino.ecf @@ -11,7 +11,6 @@ - diff --git a/library/server/ewsgi/default/cgi/default_ewsgi_application.e b/library/server/ewsgi/default/cgi/default_ewsgi_application.e new file mode 100644 index 00000000..1e582479 --- /dev/null +++ b/library/server/ewsgi/default/cgi/default_ewsgi_application.e @@ -0,0 +1,32 @@ +note + description: "Summary description for {DEFAULT_EWSGI_APPLICATION}." + date: "$Date$" + revision: "$Revision$" + +deferred class + DEFAULT_EWSGI_APPLICATION + +inherit + GW_APPLICATION_IMP + +feature {NONE} -- Initialization + + make_and_launch + local + cgi: GW_CGI_CONNECTOR + do + create cgi.make (Current) + cgi.launch + end + +note + copyright: "2011-2011, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/server/ewsgi/default/ewsgi_cgi-safe.ecf b/library/server/ewsgi/default/ewsgi_cgi-safe.ecf new file mode 100644 index 00000000..3a97046d --- /dev/null +++ b/library/server/ewsgi/default/ewsgi_cgi-safe.ecf @@ -0,0 +1,22 @@ + + + + + + /EIFGENs$ + /\.git$ + /\.svn$ + + + + + + + + + + + + + diff --git a/library/server/ewsgi/default/ewsgi_nino-safe.ecf b/library/server/ewsgi/default/ewsgi_nino-safe.ecf new file mode 100644 index 00000000..ad20e21c --- /dev/null +++ b/library/server/ewsgi/default/ewsgi_nino-safe.ecf @@ -0,0 +1,26 @@ + + + + + + /EIFGENs$ + /\.git$ + /\.svn$ + + + + + + + + + + + + + + + + + diff --git a/library/server/ewsgi/default/nino/default_ewsgi_application.e b/library/server/ewsgi/default/nino/default_ewsgi_application.e new file mode 100644 index 00000000..7f8debfc --- /dev/null +++ b/library/server/ewsgi/default/nino/default_ewsgi_application.e @@ -0,0 +1,32 @@ +note + description: "Summary description for {DEFAULT_EWSGI_APPLICATION}." + date: "$Date$" + revision: "$Revision$" + +deferred class + DEFAULT_EWSGI_APPLICATION + +inherit + GW_APPLICATION_IMP + +feature {NONE} -- Initialization + + make_and_launch + do + print ("Example: start a Nino web server on port " + port_number.out + ", %Nand reply Hello World for any request such as http://localhost:8123/%N") + (create {NINO_APPLICATION}.make_custom (agent execute, "")).listen (port_number) + end + + port_number: INTEGER = 80 + +note + copyright: "2011-2011, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/server/ewsgi/connectors/nino/src/gw_nino_application.e b/library/server/ewsgi/default/nino/nino_application.e similarity index 93% rename from library/server/ewsgi/connectors/nino/src/gw_nino_application.e rename to library/server/ewsgi/default/nino/nino_application.e index 1247261c..dd33bdd5 100644 --- a/library/server/ewsgi/connectors/nino/src/gw_nino_application.e +++ b/library/server/ewsgi/default/nino/nino_application.e @@ -1,10 +1,10 @@ note - description: "Summary description for {GW_NINO_APPLICATION}." + description: "Summary description for {NINO_APPLICATION}." date: "$Date$" revision: "$Revision$" class - GW_NINO_APPLICATION + NINO_APPLICATION create make, diff --git a/library/server/ewsgi/examples/hello_world/src/hello_world.e b/library/server/ewsgi/examples/hello_world/src/hello_world.e index d920c7de..d8bd04f3 100644 --- a/library/server/ewsgi/examples/hello_world/src/hello_world.e +++ b/library/server/ewsgi/examples/hello_world/src/hello_world.e @@ -18,7 +18,7 @@ feature {NONE} -- Initialization (create {GW_NINO_APPLICATION}.make_custom (agent execute, "")).listen (port_number) end - execute (req: EWSGI_REQUEST; res: EWSGI_RESPONSE) + execute (req: EWSGI_REQUEST; res: EWSGI_RESPONSE_STREAM) do res.write_header (200, <<["Content-Type", "text/plain"]>>) res.write_string ("Hello World!%N") diff --git a/library/server/ewsgi/examples/hello_world_with_response/hello-safe.ecf b/library/server/ewsgi/examples/hello_world_with_response/hello-safe.ecf new file mode 100644 index 00000000..ca270a86 --- /dev/null +++ b/library/server/ewsgi/examples/hello_world_with_response/hello-safe.ecf @@ -0,0 +1,29 @@ + + + + + /EIFGENs$ + /\.git$ + /\.svn$ + + + + + + + + + + + + + + + + + + + + + diff --git a/library/server/ewsgi/examples/hello_world_with_response/license.lic b/library/server/ewsgi/examples/hello_world_with_response/license.lic new file mode 100644 index 00000000..cf2d1ed9 --- /dev/null +++ b/library/server/ewsgi/examples/hello_world_with_response/license.lic @@ -0,0 +1,10 @@ +${NOTE_KEYWORD} + copyright: "2011-${YEAR}, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" diff --git a/library/server/ewsgi/examples/hello_world_with_response/src/framework/ewsgi_response.e b/library/server/ewsgi/examples/hello_world_with_response/src/framework/ewsgi_response.e new file mode 100644 index 00000000..a586880d --- /dev/null +++ b/library/server/ewsgi/examples/hello_world_with_response/src/framework/ewsgi_response.e @@ -0,0 +1,225 @@ +note + description: "[ + An EWSGI response. This may be used as is or specialized (subclassed) + if a developer wishes to reimplement their own version of the feature + 'read_message_body_block' for supporting a block-based message body + response. + ]" + author: "Paul Cohen " + status: "Draft" + +class EWSGI_RESPONSE + +create + make + +feature {NONE} -- Initialization + + make + -- Create new response object + do + is_buffered := False + ready_to_transmit := False + end_of_blocks := False + max_block_size := default_max_block_size + current_block := "" + create headers_table.make (10) + end + +feature {EWSGI_RESPONSE_APPLICATION} -- Response status + + transmit_to (res: EWSGI_RESPONSE_STREAM) + do + res.set_status_code (status) + res.write_string (headers) + from + read_block + res.write_string (last_block) +-- res.flush + until + end_of_blocks + loop + read_block + res.write_string (last_block) +-- res.flush + end + end + + ready_to_transmit: BOOLEAN + -- Is this response ready to be transmitted? + + set_ready_to_transmit + -- Set response to ready to transmit. + do + if is_buffered then + set_header ("Content-Length", current_block.count.out) +-- elseif tmp_file /= Void then +-- if tmp_file.is_open_write then +-- tmp_file.close +-- set_header ("Content-Length", tmp_file.count.out) +-- end + end + ready_to_transmit := True + ensure + ready_to_transmit + end + +feature {EWSGI_RESPONSE_APPLICATION} -- Message start line and status + + status: INTEGER + -- HTTP status code + + set_status (s: INTEGER) + -- Set 'status_code'. + do + status := s + set_header ("Status", s.out) + ensure + status = s + end + + start_line: STRING + -- HTTP message start-line + do + if attached status as st then + Result := "HTTP/1.1 " + st.out + " " + status_text (st) + crlf + else + Result := "HTTP/1.1 200 " + status_text (200) + crlf + end + end + +feature {EWSGI_RESPONSE_APPLICATION} -- Message headers + + headers: STRING + -- HTTP message headers including trailing empty line. + local + t: HASH_TABLE [STRING, STRING] + do + Result := "" + t := headers_table + from + t.start + until + t.after + loop + Result.append (t.key_for_iteration + ": " + t.item_for_iteration + crlf) + t.forth + end + Result.append (crlf) + end + + headers_table: HASH_TABLE [STRING, STRING] + -- Hash table of HTTP headers + + set_header (key, value: STRING) + -- Set the HTTP header with the given 'key' to the given 'value'. + do + headers_table.put (value, key) + ensure + headers_table.has (key) and headers_table @ key = value + end + +feature {EWSGI_RESPONSE_APPLICATION} -- Message body + + read_block + -- Read a message body block. + do + if is_buffered then + end_of_blocks := True +-- else +-- -- File based block-based output +-- -- TBD! + end + ensure + not is_buffered implies last_block.count <= max_block_size + end + + last_block: STRING + -- Last message body block that has been read. + do + Result := current_block + end + + is_buffered: BOOLEAN + -- Is the entire entity body buffered in memory (STRING)? + + end_of_blocks: BOOLEAN + -- Has the last of the entity body blocks been read? + + set_message_body (s: STRING) + -- Set the message body to 's'. Use this for when you want a memory + -- buffered response. + do + current_block := s + is_buffered := True + set_ready_to_transmit + ensure + is_buffered + ready_to_transmit + last_block.is_equal (s) + end + + max_block_size: INTEGER + -- Maximum block size returned by message body if not buffered + + set_max_block_size (block_size: INTEGER) + -- Set 'max_block_size'. + do + max_block_size := block_size + ensure + max_block_size = block_size + end + +-- write_message_block (s: STRING) +-- -- Write message body block 's' to a temporary file. Us this when +-- -- you want a non-buffered response. +-- require +-- not is_buffered +-- do +-- -- TBD! +-- ensure +-- not is_buffered +-- not ready_to_transmit +-- end + +feature {NONE} -- Implementation + +-- tmp_file_name: STRING + +-- tmp_file: detachable FILE +-- -- Created with mktmp + +-- position: INTEGER +-- -- Current read position in tmp_file + + current_block: STRING + -- Current message body block + + default_max_block_size: INTEGER = 65536 + -- Default value of 'max_block_size' + + crlf: STRING = "%/13/%/10/" + + status_text (code: INTEGER): STRING + do + inspect code + when 500 then + Result := "Internal Server Error" + when 200 then + Result := "OK" + else + Result := "Code " + code.out + end + end + +note + copyright: "2011-2011, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/server/ewsgi/examples/hello_world_with_response/src/framework/ewsgi_response_application.e b/library/server/ewsgi/examples/hello_world_with_response/src/framework/ewsgi_response_application.e new file mode 100644 index 00000000..58757f43 --- /dev/null +++ b/library/server/ewsgi/examples/hello_world_with_response/src/framework/ewsgi_response_application.e @@ -0,0 +1,57 @@ +note + description: "Summary description for {EWSGI_RESPONSE_APPLICATION} " + legal: "See notice at end of class." + status: "See notice at end of class." + date: "$Date$" + revision: "$Revision$" + +deferred class + EWSGI_RESPONSE_APPLICATION + +feature -- Execution + + execute (req: EWSGI_REQUEST; res: EWSGI_RESPONSE_STREAM) + -- Execute the request + -- See `req.input' for input stream + -- `req.environment' for the Gateway environment + -- and `res.output' for output stream + local + rs: EWSGI_RESPONSE + s: STRING + do + rs := response (req) + if rs.ready_to_transmit then + rs.transmit_to (res) + else + -- Report internal server error. + -- Response not ready to transmit! + -- Implementor of EWSGI_APPLICATION has not done his job! + create rs.make + rs.set_status (500) + rs.set_header ("Content-Type", "text/plain") + rs.set_message_body ("Incomplete server implementation: Response not ready to transmit.%NTell the programmer to finish his/her job!") + rs.transmit_to (res) + end + end + +feature -- Response + + response (request: EWSGI_REQUEST): EWSGI_RESPONSE + -- HTTP response for given 'request'. + deferred + ensure + ready_to_transmit: Result.ready_to_transmit + end + +;note + copyright: "2011-2011, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end diff --git a/library/server/ewsgi/examples/hello_world_with_response/src/hello_world.e b/library/server/ewsgi/examples/hello_world_with_response/src/hello_world.e new file mode 100644 index 00000000..5d574f5c --- /dev/null +++ b/library/server/ewsgi/examples/hello_world_with_response/src/hello_world.e @@ -0,0 +1,36 @@ +note + description : "Objects that ..." + author : "$Author$" + date : "$Date$" + revision : "$Revision$" + +class + HELLO_WORLD + +inherit + EWSGI_RESPONSE_APPLICATION + + DEFAULT_EWSGI_APPLICATION + +create + make_and_launch + +feature -- Response + + response (request: EWSGI_REQUEST): EWSGI_RESPONSE + do + create {HELLO_WORLD_RESPONSE} Result.make + Result.set_status (200) + Result.set_header ("Content-Type", "text/html; charset=utf-8") + end +note + copyright: "2011-2011, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/server/ewsgi/examples/hello_world_with_response/src/hello_world_response.e b/library/server/ewsgi/examples/hello_world_with_response/src/hello_world_response.e new file mode 100644 index 00000000..56d64da8 --- /dev/null +++ b/library/server/ewsgi/examples/hello_world_with_response/src/hello_world_response.e @@ -0,0 +1,67 @@ +note + description: "A streaming (non-buffered) Hello World example." + author: "Paul Cohen " + status: "Draft" + +class HELLO_WORLD_RESPONSE + +inherit + EWSGI_RESPONSE + redefine + make, + read_block + end + +create + make + +feature {NONE} -- Initialization + + make + do + precursor + set_ready_to_transmit + current_hello := 0 + end + +feature {NONE} -- Entity body + + read_block + -- Reads a block of 100000 lines of "Hello World". + local + i: INTEGER + do + if current_hello >= 100000 then + end_of_blocks := True + else + if current_hello = 0 then + current_block := "%N" + end + from + i := 0 + until + i = 10000 + loop + current_block.append ("Hello World ("+ current_hello.out +","+ i.out +")
%N") + i := i + 1 + end + current_hello := current_hello + i + if current_hello = 100000 then + current_block.append ("Bye bye..
") + end + end + end + + current_hello: INTEGER + +;note + copyright: "2011-2011, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/server/ewsgi/specification/ewsgi_agent_application.e b/library/server/ewsgi/specification/ewsgi_agent_application.e index 58f45846..f2e2c521 100644 --- a/library/server/ewsgi/specification/ewsgi_agent_application.e +++ b/library/server/ewsgi/specification/ewsgi_agent_application.e @@ -27,7 +27,7 @@ feature {NONE} -- Implementation request_creator: FUNCTION [ANY, TUPLE [env: EWSGI_ENVIRONMENT; input: EWSGI_INPUT_STREAM], EWSGI_REQUEST] - response_creator: FUNCTION [ANY, TUPLE [req: EWSGI_REQUEST; output: EWSGI_OUTPUT_STREAM], EWSGI_RESPONSE] + response_creator: FUNCTION [ANY, TUPLE [req: EWSGI_REQUEST; output: EWSGI_OUTPUT_STREAM], EWSGI_RESPONSE_STREAM] callback: PROCEDURE [ANY, TUPLE [req: like new_request; res: like new_response]] -- Procedure called on `execute' @@ -45,7 +45,7 @@ feature -- Factory Result := request_creator.item ([env, a_input]) end - new_response (req: EWSGI_REQUEST; a_output: EWSGI_OUTPUT_STREAM): EWSGI_RESPONSE + new_response (req: EWSGI_REQUEST; a_output: EWSGI_OUTPUT_STREAM): EWSGI_RESPONSE_STREAM do Result := response_creator.item ([req, a_output]) end diff --git a/library/server/ewsgi/specification/ewsgi_application.e b/library/server/ewsgi/specification/ewsgi_application.e index ab993eea..958888e1 100644 --- a/library/server/ewsgi/specification/ewsgi_application.e +++ b/library/server/ewsgi/specification/ewsgi_application.e @@ -33,7 +33,7 @@ feature -- Process request feature {NONE} -- Execution - execute (req: EWSGI_REQUEST; res: EWSGI_RESPONSE) + execute (req: EWSGI_REQUEST; res: EWSGI_RESPONSE_STREAM) -- Execute the request -- See `req.input' for input stream -- `req.environment' for the Gateway environment @@ -48,12 +48,12 @@ feature {NONE} -- Execution do end - post_execute (req: detachable EWSGI_REQUEST; res: detachable EWSGI_RESPONSE) + post_execute (req: detachable EWSGI_REQUEST; res: detachable EWSGI_RESPONSE_STREAM) -- Operation processed after `execute', or after `rescue_execute' do end - rescue_execute (req: detachable EWSGI_REQUEST; res: detachable EWSGI_RESPONSE; a_exception: detachable EXCEPTION) + rescue_execute (req: detachable EWSGI_REQUEST; res: detachable EWSGI_RESPONSE_STREAM; a_exception: detachable EXCEPTION) -- Operation processed on rescue of `execute' do post_execute (req, res) @@ -64,16 +64,16 @@ feature -- Factory new_request (env: EWSGI_ENVIRONMENT; a_input: EWSGI_INPUT_STREAM): EWSGI_REQUEST -- New Request context based on `env' and `a_input' --| note: you can redefine this function to create your own - --| descendant of GW_REQUEST_CONTEXT , or even to reuse/recycle existing - --| instance of GW_REQUEST_CONTEXT + --| descendant of EWSGI_REQUEST , or even to reuse/recycle existing + --| instance of EWSGI_REQUEST deferred end - new_response (req: EWSGI_REQUEST; a_output: EWSGI_OUTPUT_STREAM): EWSGI_RESPONSE + new_response (req: EWSGI_REQUEST; a_output: EWSGI_OUTPUT_STREAM): EWSGI_RESPONSE_STREAM -- New Response based on `req' and `a_output' --| note: you can redefine this function to create your own - --| descendant of GW_RESPONSE , or even to reuse/recycle existing - --| instance of GW_RESPONSE + --| descendant of EWSGI_RESPONSE_STREAM , or even to reuse/recycle existing + --| instance of EWSGI_RESPONSE_STREAM deferred end diff --git a/library/server/ewsgi/specification/response/ewsgi_response.e b/library/server/ewsgi/specification/response/ewsgi_response_stream.e similarity index 95% rename from library/server/ewsgi/specification/response/ewsgi_response.e rename to library/server/ewsgi/specification/response/ewsgi_response_stream.e index d813ad66..00c52560 100644 --- a/library/server/ewsgi/specification/response/ewsgi_response.e +++ b/library/server/ewsgi/specification/response/ewsgi_response_stream.e @@ -1,11 +1,11 @@ note - description: "Summary description for {EWSGI_RESPONSE}." + description: "Summary description for {EWSGI_RESPONSE_STREAM}." author: "" date: "$Date$" revision: "$Revision$" deferred class - EWSGI_RESPONSE + EWSGI_RESPONSE_STREAM feature {EWSGI_APPLICATION} -- Commit diff --git a/library/server/ewsgi/src/application/gw_application_imp.e b/library/server/ewsgi/src/application/gw_application_imp.e index 2821f2b1..5bec3260 100644 --- a/library/server/ewsgi/src/application/gw_application_imp.e +++ b/library/server/ewsgi/src/application/gw_application_imp.e @@ -29,7 +29,7 @@ feature -- Execution Precursor (env, a_input, a_output) end - rescue_execute (req: detachable EWSGI_REQUEST; res: detachable EWSGI_RESPONSE; a_exception: detachable EXCEPTION) + rescue_execute (req: detachable EWSGI_REQUEST; res: detachable EWSGI_RESPONSE_STREAM; a_exception: detachable EXCEPTION) -- Operation processed on rescue of `execute' do if @@ -50,9 +50,9 @@ feature -- Factory Result.execution_variables.set_variable (request_count.out, "REQUEST_COUNT") end - new_response (req: EWSGI_REQUEST; a_output: EWSGI_OUTPUT_STREAM): EWSGI_RESPONSE + new_response (req: EWSGI_REQUEST; a_output: EWSGI_OUTPUT_STREAM): EWSGI_RESPONSE_STREAM do - create {GW_RESPONSE_IMP} Result.make (a_output) + create {GW_RESPONSE_STREAM_IMP} Result.make (a_output) end ;note diff --git a/library/server/ewsgi/src/response/gw_buffered_response.e b/library/server/ewsgi/src/response/gw_buffered_response.e index b2983275..047b35cd 100644 --- a/library/server/ewsgi/src/response/gw_buffered_response.e +++ b/library/server/ewsgi/src/response/gw_buffered_response.e @@ -8,7 +8,7 @@ class GW_BUFFERED_RESPONSE inherit - EWSGI_RESPONSE + EWSGI_RESPONSE_STREAM create {EWSGI_APPLICATION} make diff --git a/library/server/ewsgi/src/response/gw_in_memory_response.e b/library/server/ewsgi/src/response/gw_in_memory_response.e index cb08a1af..b46b9ee7 100644 --- a/library/server/ewsgi/src/response/gw_in_memory_response.e +++ b/library/server/ewsgi/src/response/gw_in_memory_response.e @@ -8,7 +8,7 @@ class GW_IN_MEMORY_RESPONSE inherit - EWSGI_RESPONSE + EWSGI_RESPONSE_STREAM redefine commit end diff --git a/library/server/ewsgi/src/response/gw_response_imp.e b/library/server/ewsgi/src/response/gw_response_stream_imp.e similarity index 94% rename from library/server/ewsgi/src/response/gw_response_imp.e rename to library/server/ewsgi/src/response/gw_response_stream_imp.e index b52ae973..31402320 100644 --- a/library/server/ewsgi/src/response/gw_response_imp.e +++ b/library/server/ewsgi/src/response/gw_response_stream_imp.e @@ -1,14 +1,14 @@ note - description: "Summary description for {GW_RESPONSE_IMP}." + description: "Summary description for {GW_RESPONSE_STREAM_IMP}." author: "" date: "$Date$" revision: "$Revision$" class - GW_RESPONSE_IMP + GW_RESPONSE_STREAM_IMP inherit - EWSGI_RESPONSE + EWSGI_RESPONSE_STREAM create {EWSGI_APPLICATION} make diff --git a/library/server/ewsgi/src/support/gw_header.e b/library/server/ewsgi/src/support/gw_header.e index 936f1ed7..13d4dd1a 100644 --- a/library/server/ewsgi/src/support/gw_header.e +++ b/library/server/ewsgi/src/support/gw_header.e @@ -12,6 +12,14 @@ note class GW_HEADER +inherit + ANY + + HTTP_STATUS_CODE_MESSAGES + export + {NONE} all + end + create make @@ -84,6 +92,18 @@ feature -- Header change: general feature -- Content related header + put_status (c: INTEGER) + local + s: STRING + do + create s.make_from_string (c.out) + if attached http_status_code_message (c) as msg then + s.append_character (' ') + s.append (msg) + end + put_header_key_value ("Status", s) + end + put_content_type (t: STRING) do put_header_key_value (name_content_type, t)