Renamed write_ feature as put_
This commit is contained in:
@@ -51,7 +51,7 @@ feature -- Execution
|
|||||||
res.set_status_code ({HTTP_STATUS_CODE}.internal_server_error)
|
res.set_status_code ({HTTP_STATUS_CODE}.internal_server_error)
|
||||||
end
|
end
|
||||||
if res.message_writable then
|
if res.message_writable then
|
||||||
res.write_string ("<pre>" + l_trace + "</pre>")
|
res.put_string ("<pre>" + l_trace + "</pre>")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ feature -- Execution
|
|||||||
res.set_status_code ({HTTP_STATUS_CODE}.internal_server_error)
|
res.set_status_code ({HTTP_STATUS_CODE}.internal_server_error)
|
||||||
end
|
end
|
||||||
if res.message_writable then
|
if res.message_writable then
|
||||||
res.write_string ("<pre>" + l_trace + "</pre>")
|
res.put_string ("<pre>" + l_trace + "</pre>")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ feature -- Server
|
|||||||
res.set_status_code ({HTTP_STATUS_CODE}.internal_server_error)
|
res.set_status_code ({HTTP_STATUS_CODE}.internal_server_error)
|
||||||
end
|
end
|
||||||
if res.message_writable then
|
if res.message_writable then
|
||||||
res.write_string ("<pre>" + l_trace + "</pre>")
|
res.put_string ("<pre>" + l_trace + "</pre>")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -68,10 +68,10 @@ feature -- Status setting
|
|||||||
|
|
||||||
feature -- Header output operation
|
feature -- Header output operation
|
||||||
|
|
||||||
write_header_text (a_text: READABLE_STRING_8)
|
put_header_text (a_text: READABLE_STRING_8)
|
||||||
-- Write http header string `a_text'
|
-- Write http header string `a_text'
|
||||||
-- 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 `write_header_text' to write it.
|
-- since it is the duty of `put_header_text' to write it.
|
||||||
require
|
require
|
||||||
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
|
||||||
@@ -83,7 +83,7 @@ feature -- Header output operation
|
|||||||
message_writable: message_writable
|
message_writable: message_writable
|
||||||
end
|
end
|
||||||
|
|
||||||
write_header_lines (a_lines: ITERABLE [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])
|
put_header_lines (a_lines: ITERABLE [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])
|
||||||
require
|
require
|
||||||
status_set: status_is_set
|
status_set: status_is_set
|
||||||
header_not_committed: not header_committed
|
header_not_committed: not header_committed
|
||||||
@@ -96,14 +96,14 @@ feature -- Header output operation
|
|||||||
|
|
||||||
feature -- Output operation
|
feature -- Output operation
|
||||||
|
|
||||||
write_string (s: READABLE_STRING_8)
|
put_string (s: READABLE_STRING_8)
|
||||||
-- Send the string `s'
|
-- Send the string `s'
|
||||||
require
|
require
|
||||||
message_writable: message_writable
|
message_writable: message_writable
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
write_substring (s: READABLE_STRING_8; a_begin_index, a_end_index: INTEGER)
|
put_substring (s: READABLE_STRING_8; a_begin_index, a_end_index: INTEGER)
|
||||||
-- Send the substring `s[a_begin_index:a_end_index]'
|
-- Send the substring `s[a_begin_index:a_end_index]'
|
||||||
require
|
require
|
||||||
message_writable: message_writable
|
message_writable: message_writable
|
||||||
|
|||||||
@@ -75,14 +75,14 @@ feature -- Status setting
|
|||||||
|
|
||||||
feature -- Header output operation
|
feature -- Header output operation
|
||||||
|
|
||||||
write_header_text (a_text: READABLE_STRING_8)
|
put_header_text (a_text: READABLE_STRING_8)
|
||||||
do
|
do
|
||||||
write (a_text)
|
write (a_text)
|
||||||
write (crlf)
|
write (crlf)
|
||||||
header_committed := True
|
header_committed := True
|
||||||
end
|
end
|
||||||
|
|
||||||
write_header_lines (a_lines: ITERABLE [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])
|
put_header_lines (a_lines: ITERABLE [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])
|
||||||
local
|
local
|
||||||
h: STRING_8
|
h: STRING_8
|
||||||
do
|
do
|
||||||
@@ -97,18 +97,18 @@ feature -- Header output operation
|
|||||||
h.append_character ('%R')
|
h.append_character ('%R')
|
||||||
h.append_character ('%N')
|
h.append_character ('%N')
|
||||||
end
|
end
|
||||||
write_header_text (h)
|
put_header_text (h)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Output operation
|
feature -- Output operation
|
||||||
|
|
||||||
write_string (s: READABLE_STRING_8)
|
put_string (s: READABLE_STRING_8)
|
||||||
-- Send the string `s'
|
-- Send the string `s'
|
||||||
do
|
do
|
||||||
write (s)
|
write (s)
|
||||||
end
|
end
|
||||||
|
|
||||||
write_substring (s: READABLE_STRING_8; start_index, end_index: INTEGER)
|
put_substring (s: READABLE_STRING_8; start_index, end_index: INTEGER)
|
||||||
-- Send the substring `start_index:end_index]'
|
-- Send the substring `start_index:end_index]'
|
||||||
--| Could be optimized according to the target output
|
--| Could be optimized according to the target output
|
||||||
do
|
do
|
||||||
|
|||||||
@@ -71,30 +71,21 @@ feature -- Status setting
|
|||||||
Result := wgi_response.status_code
|
Result := wgi_response.status_code
|
||||||
end
|
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
|
feature -- Header output operation
|
||||||
|
|
||||||
write_header_text (a_headers: READABLE_STRING_8)
|
put_header_text (a_headers: READABLE_STRING_8)
|
||||||
require
|
require
|
||||||
status_set: status_is_set
|
status_set: status_is_set
|
||||||
header_not_committed: not header_committed
|
header_not_committed: not header_committed
|
||||||
do
|
do
|
||||||
wgi_response.write_header_text (a_headers)
|
wgi_response.put_header_text (a_headers)
|
||||||
ensure
|
ensure
|
||||||
status_set: status_is_set
|
status_set: status_is_set
|
||||||
header_committed: header_committed
|
header_committed: header_committed
|
||||||
message_writable: message_writable
|
message_writable: message_writable
|
||||||
end
|
end
|
||||||
|
|
||||||
write_header (a_status_code: INTEGER; a_headers: detachable ARRAY [TUPLE [key: READABLE_STRING_8; value: READABLE_STRING_8]])
|
put_header (a_status_code: INTEGER; a_headers: detachable ARRAY [TUPLE [key: READABLE_STRING_8; value: READABLE_STRING_8]])
|
||||||
-- Send headers with status `a_status', and headers from `a_headers'
|
-- Send headers with status `a_status', and headers from `a_headers'
|
||||||
require
|
require
|
||||||
status_not_set: not status_is_set
|
status_not_set: not status_is_set
|
||||||
@@ -116,65 +107,104 @@ feature -- Header output operation
|
|||||||
i := i + 1
|
i := i + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
wgi_response.write_header_text (h.string)
|
wgi_response.put_header_text (h.string)
|
||||||
ensure
|
ensure
|
||||||
header_committed: header_committed
|
header_committed: header_committed
|
||||||
status_set: status_is_set
|
status_set: status_is_set
|
||||||
message_writable: message_writable
|
message_writable: message_writable
|
||||||
end
|
end
|
||||||
|
|
||||||
write_header_lines (a_lines: ITERABLE [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])
|
put_header_lines (a_lines: ITERABLE [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])
|
||||||
do
|
do
|
||||||
wgi_response.write_header_lines (a_lines)
|
wgi_response.put_header_lines (a_lines)
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Obsolete: Header output operation
|
||||||
|
|
||||||
|
write_header_text (a_headers: READABLE_STRING_8)
|
||||||
|
obsolete "[2011-dec-15] use put_header_text"
|
||||||
|
do
|
||||||
|
put_header_text (a_headers)
|
||||||
|
end
|
||||||
|
|
||||||
|
write_header (a_status_code: INTEGER; a_headers: detachable ARRAY [TUPLE [key: READABLE_STRING_8; value: READABLE_STRING_8]])
|
||||||
|
obsolete "[2011-dec-15] use put_header"
|
||||||
|
do
|
||||||
|
put_header (a_status_code, a_headers)
|
||||||
|
end
|
||||||
|
|
||||||
|
write_header_lines (a_lines: ITERABLE [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])
|
||||||
|
obsolete "[2011-dec-15] use put_header_lines"
|
||||||
|
do
|
||||||
|
put_header_lines (a_lines)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Output operation
|
feature -- Output operation
|
||||||
|
|
||||||
write_string (s: READABLE_STRING_8)
|
write_string (s: READABLE_STRING_8)
|
||||||
|
obsolete "[2011-dec-15] use put_string"
|
||||||
|
do
|
||||||
|
put_string (s)
|
||||||
|
end
|
||||||
|
|
||||||
|
write_substring (s: READABLE_STRING_8; a_begin_index, a_end_index: INTEGER)
|
||||||
|
obsolete "[2011-dec-15] use put_substring"
|
||||||
|
do
|
||||||
|
put_substring (s, a_begin_index, a_end_index)
|
||||||
|
end
|
||||||
|
|
||||||
|
put_string (s: READABLE_STRING_8)
|
||||||
-- Send the string `s'
|
-- Send the string `s'
|
||||||
require
|
require
|
||||||
message_writable: message_writable
|
message_writable: message_writable
|
||||||
do
|
do
|
||||||
wgi_response.write_string (s)
|
wgi_response.put_string (s)
|
||||||
end
|
end
|
||||||
|
|
||||||
write_substring (s: READABLE_STRING_8; a_begin_index, a_end_index: INTEGER)
|
put_substring (s: READABLE_STRING_8; a_begin_index, a_end_index: INTEGER)
|
||||||
-- Send the substring `s[a_begin_index:a_end_index]'
|
-- Send the substring `s[a_begin_index:a_end_index]'
|
||||||
require
|
require
|
||||||
message_writable: message_writable
|
message_writable: message_writable
|
||||||
do
|
do
|
||||||
wgi_response.write_substring (s, a_begin_index, a_end_index)
|
wgi_response.put_substring (s, a_begin_index, a_end_index)
|
||||||
end
|
end
|
||||||
|
|
||||||
write_chunk (s: detachable READABLE_STRING_8)
|
put_chunk (s: detachable READABLE_STRING_8; a_extension: detachable READABLE_STRING_8)
|
||||||
-- Write chunk `s'
|
-- Write chunk `s'
|
||||||
-- If s is Void, this means this was the final chunk
|
-- If s is Void, this means this was the final chunk
|
||||||
-- Note: that you should have header
|
-- Note: that you should have header
|
||||||
-- "Transfer-Encoding: chunked"
|
-- "Transfer-Encoding: chunked"
|
||||||
require
|
require
|
||||||
message_writable: message_writable
|
message_writable: message_writable
|
||||||
|
valid_chunk_extension: a_extension /= Void implies not a_extension.has ('%N') and not not a_extension.has ('%R')
|
||||||
local
|
local
|
||||||
hex: STRING
|
l_chunk_size_line: STRING_8
|
||||||
i: INTEGER
|
i: INTEGER
|
||||||
do
|
do
|
||||||
if s /= Void then
|
if s /= Void then
|
||||||
--| Remove all left '0'
|
--| Remove all left '0'
|
||||||
hex := s.count.to_hex_string
|
l_chunk_size_line := s.count.to_hex_string
|
||||||
from
|
from
|
||||||
i := 1
|
i := 1
|
||||||
until
|
until
|
||||||
hex[i] /= '0'
|
l_chunk_size_line[i] /= '0'
|
||||||
loop
|
loop
|
||||||
i := i + 1
|
i := i + 1
|
||||||
end
|
end
|
||||||
if i > 1 then
|
if i > 1 then
|
||||||
hex := hex.substring (i, hex.count)
|
l_chunk_size_line := l_chunk_size_line.substring (i, l_chunk_size_line.count)
|
||||||
end
|
end
|
||||||
write_string (hex + {HTTP_CONSTANTS}.crlf)
|
|
||||||
write_string (s)
|
if a_extension /= Void then
|
||||||
write_string ({HTTP_CONSTANTS}.crlf)
|
l_chunk_size_line.append_character (';')
|
||||||
|
l_chunk_size_line.append (a_extension)
|
||||||
|
end
|
||||||
|
l_chunk_size_line.append ({HTTP_CONSTANTS}.crlf)
|
||||||
|
put_string (l_chunk_size_line)
|
||||||
|
put_string (s)
|
||||||
|
put_string ({HTTP_CONSTANTS}.crlf)
|
||||||
else
|
else
|
||||||
write_string ("0" + {HTTP_CONSTANTS}.crlf)
|
put_string ("0" + {HTTP_CONSTANTS}.crlf)
|
||||||
end
|
end
|
||||||
flush
|
flush
|
||||||
end
|
end
|
||||||
@@ -208,12 +238,12 @@ feature -- Redirect
|
|||||||
do
|
do
|
||||||
if header_committed then
|
if header_committed then
|
||||||
-- This might be a trouble about content-length
|
-- This might be a trouble about content-length
|
||||||
write_string ("Headers already sent.%NCannot redirect, for now please follow this <a %"href=%"" + a_url + "%">link</a> instead%N")
|
put_string ("Headers already sent.%NCannot redirect, for now please follow this <a %"href=%"" + a_url + "%">link</a> instead%N")
|
||||||
else
|
else
|
||||||
create h.make_with_count (1)
|
create h.make_with_count (1)
|
||||||
h.put_location (a_url)
|
h.put_location (a_url)
|
||||||
set_status_code (a_status_code)
|
set_status_code (a_status_code)
|
||||||
write_header_text (h.string)
|
put_header_text (h.string)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -232,15 +262,15 @@ feature -- Redirect
|
|||||||
do
|
do
|
||||||
if header_committed then
|
if header_committed then
|
||||||
-- This might be a trouble about content-length
|
-- This might be a trouble about content-length
|
||||||
write_string ("Headers already sent.%NCannot redirect, for now please follow this <a %"href=%"" + a_url + "%">link</a> instead%N")
|
put_string ("Headers already sent.%NCannot redirect, for now please follow this <a %"href=%"" + a_url + "%">link</a> instead%N")
|
||||||
else
|
else
|
||||||
create h.make_with_count (1)
|
create h.make_with_count (1)
|
||||||
h.put_location (a_url)
|
h.put_location (a_url)
|
||||||
h.put_content_length (a_content.count)
|
h.put_content_length (a_content.count)
|
||||||
h.put_content_type (a_content_type)
|
h.put_content_type (a_content_type)
|
||||||
set_status_code ({HTTP_STATUS_CODE}.moved_permanently)
|
set_status_code ({HTTP_STATUS_CODE}.moved_permanently)
|
||||||
write_header_text (h.string)
|
put_header_text (h.string)
|
||||||
write_string (a_content)
|
put_string (a_content)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user