diff --git a/library/server/ewsgi/connectors/null/src/wgi_null_output_stream.e b/library/server/ewsgi/connectors/null/src/wgi_null_output_stream.e index 7fea6a32..16fdbf73 100644 --- a/library/server/ewsgi/connectors/null/src/wgi_null_output_stream.e +++ b/library/server/ewsgi/connectors/null/src/wgi_null_output_stream.e @@ -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 NULL script + put_status_line (a_code: INTEGER; a_reason_phrase: detachable READABLE_STRING_8) + -- 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 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 e881197e..d66c934d 100644 --- a/library/server/ewsgi/examples/hello_world/src/hello_world.e +++ b/library/server/ewsgi/examples/hello_world/src/hello_world.e @@ -23,8 +23,8 @@ feature {NONE} -- Initialization execute (req: WGI_REQUEST; res: WGI_RESPONSE) do - res.set_status_code (200) - res.put_header_lines (<<["Content-Type", "text/plain"]>>) + res.set_status_code (200, Void) + res.put_header_text ("Content-Type: text/plain%R%N") res.put_string ("Hello World!%N") end diff --git a/library/server/ewsgi/specification/response/wgi_response.e b/library/server/ewsgi/specification/response/wgi_response.e index 3822fc82..25a570a4 100644 --- a/library/server/ewsgi/specification/response/wgi_response.e +++ b/library/server/ewsgi/specification/response/wgi_response.e @@ -82,6 +82,7 @@ feature -- Header output operation -- It should not contain the ending CR LF CR LF -- since it is the duty of `put_header_text' to write it. require + a_text_has_single_ending_crlf: a_text.count > 2 implies not a_text.substring (a_text.count - 2, a_text.count).same_string ("%R%N") a_text_does_not_has_ending_crlf_crlf: a_text.count > 4 implies not a_text.substring (a_text.count - 4, a_text.count).same_string ("%R%N%R%N") status_set: status_is_set header_not_committed: not header_committed diff --git a/library/server/wsf/src/wsf_response.e b/library/server/wsf/src/wsf_response.e index 17ed25c1..4e4b16c7 100644 --- a/library/server/wsf/src/wsf_response.e +++ b/library/server/wsf/src/wsf_response.e @@ -100,14 +100,16 @@ feature -- Status setting feature -- Header output operation - put_header_text (a_headers: READABLE_STRING_8) - -- Sent `a_headers' and just before send the status code + put_header_text (a_text: READABLE_STRING_8) + -- Sent `a_text' and just before send the status code require status_set: status_is_set header_not_committed: not header_committed + a_text_ends_with_single_crlf: a_text.count > 2 implies not a_text.substring (a_text.count - 2, a_text.count).same_string ("%R%N") + a_text_does_not_end_with_double_crlf: a_text.count > 4 implies not a_text.substring (a_text.count - 4, a_text.count).same_string ("%R%N%R%N") do wgi_response.set_status_code (status_code, status_reason_phrase) - wgi_response.put_header_text (a_headers) + wgi_response.put_header_text (a_text) ensure status_set: status_is_set status_committed: status_committed