Fixed compilation

This commit is contained in:
Jocelyn Fiat
2012-04-12 12:25:34 +02:00
parent 3bbf356f19
commit 1403cc5c09
4 changed files with 17 additions and 11 deletions

View File

@@ -36,21 +36,24 @@ feature {NONE} -- Initialization
feature -- Status writing 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' -- <Precursor>
--| Note this is a default implementation, and could be redefined
--| for instance in relation to NPH NULL script
local local
s: STRING s: STRING
m: detachable READABLE_STRING_8
do do
if a_code /= 200 then if a_code /= 200 then
create s.make (16) create s.make (16)
s.append ("Status:") s.append ("Status:")
s.append_character (' ') s.append_character (' ')
s.append_integer (a_code) 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_character (' ')
s.append_string (l_status_message) s.append_string (m)
end end
put_header_line (s) put_header_line (s)
end end

View File

@@ -23,8 +23,8 @@ feature {NONE} -- Initialization
execute (req: WGI_REQUEST; res: WGI_RESPONSE) execute (req: WGI_REQUEST; res: WGI_RESPONSE)
do do
res.set_status_code (200) res.set_status_code (200, Void)
res.put_header_lines (<<["Content-Type", "text/plain"]>>) res.put_header_text ("Content-Type: text/plain%R%N")
res.put_string ("Hello World!%N") res.put_string ("Hello World!%N")
end end

View File

@@ -82,6 +82,7 @@ feature -- Header output operation
-- It should not contain the ending CR LF CR LF -- It should not contain the ending CR LF CR LF
-- since it is the duty of `put_header_text' to write it. -- since it is the duty of `put_header_text' to write it.
require 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") 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 status_set: status_is_set
header_not_committed: not header_committed header_not_committed: not header_committed

View File

@@ -100,14 +100,16 @@ feature -- Status setting
feature -- Header output operation feature -- Header output operation
put_header_text (a_headers: READABLE_STRING_8) put_header_text (a_text: READABLE_STRING_8)
-- Sent `a_headers' and just before send the status code -- Sent `a_text' and just before send the status code
require require
status_set: status_is_set status_set: status_is_set
header_not_committed: not header_committed 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 do
wgi_response.set_status_code (status_code, status_reason_phrase) 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 ensure
status_set: status_is_set status_set: status_is_set
status_committed: status_committed status_committed: status_committed