Added WSF_RESPONSE.put_file_content (f: FILE, a_offset: INTEGER; a_count: INTEGER) to allow potential future optimization.
This commit is contained in:
@@ -131,6 +131,12 @@ feature -- Output operation
|
|||||||
wgi_response.put_substring (s, a_begin_index, a_end_index)
|
wgi_response.put_substring (s, a_begin_index, a_end_index)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
put_file_content (f: FILE; a_offset: INTEGER; a_count: INTEGER)
|
||||||
|
-- Send `a_count' bytes from the content of file `f' starting at offset `a_offset'.
|
||||||
|
do
|
||||||
|
wgi_response.put_file_content (f, a_offset, a_count)
|
||||||
|
end
|
||||||
|
|
||||||
flush
|
flush
|
||||||
-- Flush if it makes sense
|
-- Flush if it makes sense
|
||||||
do
|
do
|
||||||
|
|||||||
@@ -142,6 +142,14 @@ feature -- Output operation
|
|||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
|
put_file_content (f: FILE; a_offset: INTEGER; a_count: INTEGER)
|
||||||
|
-- Send `a_count' bytes from the content of file `f' starting at offset `a_offset'.
|
||||||
|
require
|
||||||
|
message_writable: message_writable
|
||||||
|
not_too_big: a_offset + a_count <= f.count
|
||||||
|
deferred
|
||||||
|
end
|
||||||
|
|
||||||
flush
|
flush
|
||||||
-- Flush if it makes sense
|
-- Flush if it makes sense
|
||||||
deferred
|
deferred
|
||||||
|
|||||||
@@ -37,6 +37,49 @@ feature -- Output
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
put_file_content (a_file: FILE; a_offset: INTEGER; a_count: INTEGER)
|
||||||
|
-- Send `a_count' bytes from the content of file `a_file' starting at offset `a_offset'.
|
||||||
|
--| Could be redefine for optimization.
|
||||||
|
require
|
||||||
|
is_open_write: is_open_write
|
||||||
|
a_file_not_void: a_file /= Void
|
||||||
|
local
|
||||||
|
l_close_needed: BOOLEAN
|
||||||
|
n: INTEGER
|
||||||
|
s: STRING
|
||||||
|
do
|
||||||
|
if a_file.exists and then a_file.is_access_readable then
|
||||||
|
if a_file.is_open_read then
|
||||||
|
l_close_needed := False
|
||||||
|
else
|
||||||
|
l_close_needed := True
|
||||||
|
a_file.open_read
|
||||||
|
end
|
||||||
|
from
|
||||||
|
n := a_count
|
||||||
|
if a_offset > 0 then
|
||||||
|
a_file.move (a_offset)
|
||||||
|
end
|
||||||
|
until
|
||||||
|
a_file.exhausted or n <= 0
|
||||||
|
loop
|
||||||
|
a_file.read_stream (n.min (4_096))
|
||||||
|
s := a_file.last_string
|
||||||
|
if s.is_empty then
|
||||||
|
-- network error?
|
||||||
|
n := 0
|
||||||
|
else
|
||||||
|
n := n - s.count
|
||||||
|
check n >= 0 end
|
||||||
|
put_string (s)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if l_close_needed then
|
||||||
|
a_file.close
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
put_character (c: CHARACTER_8)
|
put_character (c: CHARACTER_8)
|
||||||
-- Write `c' to output stream.
|
-- Write `c' to output stream.
|
||||||
--| Could be redefined for optimization
|
--| Could be redefined for optimization
|
||||||
|
|||||||
@@ -103,6 +103,12 @@ feature -- Output operation
|
|||||||
output.put_substring (s, start_index, end_index)
|
output.put_substring (s, start_index, end_index)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
put_file_content (f: FILE; a_offset: INTEGER; a_count: INTEGER)
|
||||||
|
-- Send `a_count' bytes from the content of file `f' starting at offset `a_offset'.
|
||||||
|
do
|
||||||
|
output.put_file_content (f, a_offset, a_count)
|
||||||
|
end
|
||||||
|
|
||||||
flush
|
flush
|
||||||
do
|
do
|
||||||
output.flush
|
output.flush
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ inherit
|
|||||||
put_character,
|
put_character,
|
||||||
put_string,
|
put_string,
|
||||||
put_substring,
|
put_substring,
|
||||||
|
put_file_content,
|
||||||
flush,
|
flush,
|
||||||
message_writable,
|
message_writable,
|
||||||
message_committed
|
message_committed
|
||||||
@@ -108,6 +109,13 @@ feature -- Output operation
|
|||||||
Precursor (s, a_begin_index, a_end_index)
|
Precursor (s, a_begin_index, a_end_index)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
put_file_content (f: FILE; a_offset: INTEGER; a_count: INTEGER)
|
||||||
|
-- Send `a_count' bytes from the content of file `f' starting at offset `a_offset'.
|
||||||
|
do
|
||||||
|
process_header
|
||||||
|
Precursor (f, a_offset, a_count)
|
||||||
|
end
|
||||||
|
|
||||||
flush
|
flush
|
||||||
-- Flush if it makes sense
|
-- Flush if it makes sense
|
||||||
do
|
do
|
||||||
|
|||||||
@@ -383,6 +383,16 @@ feature -- Body
|
|||||||
increment_transfered_content_length (a_end_index - a_begin_index + 1)
|
increment_transfered_content_length (a_end_index - a_begin_index + 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
put_file_content (f: FILE; a_offset: INTEGER; a_count: INTEGER)
|
||||||
|
-- Send `a_count' bytes from the content of file `f' starting at offset `a_offset'.
|
||||||
|
require
|
||||||
|
message_writable: message_writable
|
||||||
|
not_too_big: a_offset + a_count <= f.count
|
||||||
|
do
|
||||||
|
wgi_response.put_file_content (f, a_offset, a_count)
|
||||||
|
increment_transfered_content_length (a_count)
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Chunk body
|
feature -- Chunk body
|
||||||
|
|
||||||
put_chunk (a_content: READABLE_STRING_8; a_ext: detachable READABLE_STRING_8)
|
put_chunk (a_content: READABLE_STRING_8; a_ext: detachable READABLE_STRING_8)
|
||||||
@@ -572,7 +582,7 @@ feature {NONE} -- Implemenation
|
|||||||
end
|
end
|
||||||
|
|
||||||
note
|
note
|
||||||
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
|
copyright: "2011-2016, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
|
||||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
source: "[
|
source: "[
|
||||||
Eiffel Software
|
Eiffel Software
|
||||||
|
|||||||
Reference in New Issue
Block a user