Added WSF_RESPONSE.write_chunk (s: ?READABLE_STRING_8)
to help user sending chunk with "Transfer-Encoding: chunked"
This commit is contained in:
@@ -92,6 +92,7 @@ feature -- Execution
|
||||
s: STRING_8
|
||||
do
|
||||
l_url := req.script_url ("/home")
|
||||
|
||||
n := 3
|
||||
create h.make
|
||||
h.put_refresh (l_url, 5)
|
||||
@@ -112,7 +113,7 @@ feature -- Execution
|
||||
else
|
||||
s.append ("%NRedirected to " + l_url + " in 1 second :%N")
|
||||
end
|
||||
write_chunk (s, res); s.wipe_out
|
||||
res.write_chunk (s); s.wipe_out
|
||||
from
|
||||
i := 1
|
||||
until
|
||||
@@ -122,26 +123,15 @@ feature -- Execution
|
||||
if i \\ 100 = 0 then
|
||||
s.append_character ('%N')
|
||||
end
|
||||
write_chunk (s, res); s.wipe_out
|
||||
res.write_chunk (s); s.wipe_out
|
||||
e.sleep (1_000_000)
|
||||
i := i + 1
|
||||
end
|
||||
n := n - 1
|
||||
end
|
||||
s.append ("%NYou are now being redirected...%N")
|
||||
write_chunk (s, res); s.wipe_out
|
||||
write_chunk (Void, res)
|
||||
end
|
||||
|
||||
write_chunk (s: detachable READABLE_STRING_8; res: WSF_RESPONSE)
|
||||
do
|
||||
if s /= Void then
|
||||
res.write_string (s.count.to_hex_string + {HTTP_CONSTANTS}.crlf)
|
||||
res.write_string (s)
|
||||
else
|
||||
res.write_string ("0" + {HTTP_CONSTANTS}.crlf)
|
||||
end
|
||||
res.flush
|
||||
res.write_chunk (s); s.wipe_out
|
||||
res.write_chunk (Void)
|
||||
end
|
||||
|
||||
execute_home (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
|
||||
@@ -132,6 +132,37 @@ feature -- Output operation
|
||||
wgi_response.write_substring (s, a_begin_index, a_end_index)
|
||||
end
|
||||
|
||||
write_chunk (s: detachable READABLE_STRING_8)
|
||||
-- Write chunk `s'
|
||||
-- If s is Void, this means this was the final chunk
|
||||
-- Note: that you should have header
|
||||
-- "Transfer-Encoding: chunked"
|
||||
local
|
||||
hex: STRING
|
||||
i: INTEGER
|
||||
do
|
||||
if s /= Void then
|
||||
--| Remove all left '0'
|
||||
hex := s.count.to_hex_string
|
||||
from
|
||||
i := 1
|
||||
until
|
||||
hex[i] /= '0'
|
||||
loop
|
||||
i := i + 1
|
||||
end
|
||||
if i > 1 then
|
||||
hex := hex.substring (i, hex.count)
|
||||
end
|
||||
write_string (hex + {HTTP_CONSTANTS}.crlf)
|
||||
write_string (s)
|
||||
write_string ({HTTP_CONSTANTS}.crlf)
|
||||
else
|
||||
write_string ("0" + {HTTP_CONSTANTS}.crlf)
|
||||
end
|
||||
flush
|
||||
end
|
||||
|
||||
write_file_content (fn: READABLE_STRING_8)
|
||||
-- Send the content of file `fn'
|
||||
require
|
||||
|
||||
Reference in New Issue
Block a user