Added WSF_RESPONSE.write_chunk (s: ?READABLE_STRING_8)

to help user sending chunk with "Transfer-Encoding: chunked"
This commit is contained in:
Jocelyn Fiat
2011-12-01 18:22:47 +01:00
parent 1b92403045
commit fff7a5c96d
2 changed files with 36 additions and 15 deletions

View File

@@ -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