Compare commits
7 Commits
es_rev9957
...
net_sendfi
| Author | SHA1 | Date | |
|---|---|---|---|
| 392c4d570a | |||
| 2cc425dc38 | |||
| 27c77721fd | |||
| c2202e82f6 | |||
| 72a40a2673 | |||
| 2fbffd0c1e | |||
| 50c1adc365 |
@@ -20,15 +20,16 @@ feature
|
|||||||
|
|
||||||
initialize_controls
|
initialize_controls
|
||||||
do
|
do
|
||||||
Precursor
|
|
||||||
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", "Grid Demo"))
|
|
||||||
create datasource.make_news
|
create datasource.make_news
|
||||||
create search_query.make (create {GOOGLE_AUTOCOMPLETION}.make)
|
create search_query.make (create {GOOGLE_AUTOCOMPLETION}.make)
|
||||||
search_query.add_class ("form-control")
|
search_query.add_class ("form-control")
|
||||||
|
create grid.make (<<create {WSF_GRID_COLUMN}.make ("Title", "title"), create {WSF_GRID_COLUMN}.make ("Content", "content")>>, datasource)
|
||||||
|
|
||||||
|
Precursor
|
||||||
|
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", "Grid Demo"))
|
||||||
search_query.set_change_event (agent change_query)
|
search_query.set_change_event (agent change_query)
|
||||||
control.add_control (search_query)
|
control.add_control (search_query)
|
||||||
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h2", "", "Results"))
|
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h2", "", "Results"))
|
||||||
create grid.make (<<create {WSF_GRID_COLUMN}.make ("Title", "title"), create {WSF_GRID_COLUMN}.make ("Content", "content")>>, datasource)
|
|
||||||
control.add_control (grid)
|
control.add_control (grid)
|
||||||
navbar.set_active (2)
|
navbar.set_active (2)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,15 +20,17 @@ feature
|
|||||||
|
|
||||||
initialize_controls
|
initialize_controls
|
||||||
do
|
do
|
||||||
Precursor
|
|
||||||
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", " Repeater Demo"))
|
|
||||||
create datasource.make_news
|
create datasource.make_news
|
||||||
|
create repeater.make (datasource)
|
||||||
create search_query.make (create {GOOGLE_AUTOCOMPLETION}.make)
|
create search_query.make (create {GOOGLE_AUTOCOMPLETION}.make)
|
||||||
search_query.add_class ("form-control")
|
search_query.add_class ("form-control")
|
||||||
|
|
||||||
|
Precursor
|
||||||
|
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", " Repeater Demo"))
|
||||||
search_query.set_change_event (agent change_query)
|
search_query.set_change_event (agent change_query)
|
||||||
control.add_control (search_query)
|
control.add_control (search_query)
|
||||||
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h2", "", "Results"))
|
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h2", "", "Results"))
|
||||||
create repeater.make (datasource)
|
|
||||||
control.add_control (repeater)
|
control.add_control (repeater)
|
||||||
navbar.set_active (3)
|
navbar.set_active (3)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ feature
|
|||||||
cats_container: WSF_FORM_ELEMENT_CONTROL [LIST [STRING_32]]
|
cats_container: WSF_FORM_ELEMENT_CONTROL [LIST [STRING_32]]
|
||||||
source: INCREASING_PROGRESSSOURCE
|
source: INCREASING_PROGRESSSOURCE
|
||||||
do
|
do
|
||||||
Precursor
|
|
||||||
create form.make
|
create form.make
|
||||||
--Number 1
|
--Number 1
|
||||||
create textbox1.make ({STRING_32} "1")
|
create textbox1.make ({STRING_32} "1")
|
||||||
@@ -64,24 +63,33 @@ feature
|
|||||||
form.add_control (cats_container)
|
form.add_control (cats_container)
|
||||||
--Button 1
|
--Button 1
|
||||||
create button1.make ("Update")
|
create button1.make ("Update")
|
||||||
button1.set_click_event (agent handle_click)
|
|
||||||
button1.add_class ("col-lg-offset-2")
|
button1.add_class ("col-lg-offset-2")
|
||||||
form.add_control (button1)
|
form.add_control (button1)
|
||||||
--Button 2
|
--Button 2
|
||||||
create button2.make ("Start Modal Grid")
|
create button2.make ("Start Modal Grid")
|
||||||
button2.set_click_event (agent run_modal)
|
|
||||||
form.add_control (button2)
|
form.add_control (button2)
|
||||||
--Result
|
--Result
|
||||||
create result_html.make ("p", "")
|
create result_html.make ("p", "")
|
||||||
form.add_control (create {WSF_FORM_ELEMENT_CONTROL [STRING_32]}.make ("Result", result_html))
|
form.add_control (create {WSF_FORM_ELEMENT_CONTROL [STRING_32]}.make ("Result", result_html))
|
||||||
control.add_control (form)
|
|
||||||
|
|
||||||
--Progress bar
|
--Progress bar
|
||||||
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h4", "", "Autoincrementing progressbar"))
|
|
||||||
create source.make
|
create source.make
|
||||||
create progress.make_with_source (source)
|
create progress.make_with_source (source)
|
||||||
source.set_control (progress)
|
source.set_control (progress)
|
||||||
progress.set_isolation (true)
|
progress.set_isolation (true)
|
||||||
|
|
||||||
|
|
||||||
|
Precursor
|
||||||
|
|
||||||
|
control.add_control (form)
|
||||||
|
|
||||||
|
-- Actions
|
||||||
|
button1.set_click_event (agent handle_click)
|
||||||
|
button2.set_click_event (agent run_modal)
|
||||||
|
|
||||||
|
|
||||||
|
--Progress bar
|
||||||
|
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h4", "", "Autoincrementing progressbar"))
|
||||||
control.add_control (progress)
|
control.add_control (progress)
|
||||||
navbar.set_active (1)
|
navbar.set_active (1)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ feature -- Implementation
|
|||||||
|
|
||||||
initialize_controls
|
initialize_controls
|
||||||
do
|
do
|
||||||
Precursor
|
|
||||||
create slider.make
|
create slider.make
|
||||||
--slider.add_control (form, Void)
|
--slider.add_control (form, Void)
|
||||||
--slider.add_image ("http://www.placesmustseen.com/wp-content/uploads/2013/01/paris-eiffel-tower.jpg", "Eiffel Tower")
|
--slider.add_image ("http://www.placesmustseen.com/wp-content/uploads/2013/01/paris-eiffel-tower.jpg", "Eiffel Tower")
|
||||||
@@ -28,6 +27,8 @@ feature -- Implementation
|
|||||||
slider.add_image ("http://31.media.tumblr.com/5b5ae35c4f88d4b80aeb21e36263c6e6/tumblr_mtw7mhZsCe1st5lhmo1_1280.jpg", "landscape")
|
slider.add_image ("http://31.media.tumblr.com/5b5ae35c4f88d4b80aeb21e36263c6e6/tumblr_mtw7mhZsCe1st5lhmo1_1280.jpg", "landscape")
|
||||||
slider.add_image ("http://25.media.tumblr.com/403969159fb1642e67ed702f28e966e0/tumblr_muuig0890N1st5lhmo1_1280.jpg", "landscape")
|
slider.add_image ("http://25.media.tumblr.com/403969159fb1642e67ed702f28e966e0/tumblr_muuig0890N1st5lhmo1_1280.jpg", "landscape")
|
||||||
slider.add_image ("http://24.media.tumblr.com/d349779e7216167e7c0ca3af66817794/tumblr_mufrlh9WqW1st5lhmo1_1280.jpg", "landscape")
|
slider.add_image ("http://24.media.tumblr.com/d349779e7216167e7c0ca3af66817794/tumblr_mufrlh9WqW1st5lhmo1_1280.jpg", "landscape")
|
||||||
|
|
||||||
|
Precursor
|
||||||
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", " Image Slider Demo"))
|
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", " Image Slider Demo"))
|
||||||
control.add_control (slider)
|
control.add_control (slider)
|
||||||
navbar.set_active (4)
|
navbar.set_active (4)
|
||||||
|
|||||||
@@ -21,20 +21,25 @@ feature -- Implementation
|
|||||||
initialize_controls
|
initialize_controls
|
||||||
local
|
local
|
||||||
do
|
do
|
||||||
|
create form.make
|
||||||
|
create filebox.make
|
||||||
|
create n1_container.make ("File Upload", filebox)
|
||||||
|
create filebox2.make
|
||||||
|
create n2_container.make ("Auto start Upload", filebox2)
|
||||||
|
create filebox3.make_with_image_preview
|
||||||
|
create n3_container.make ("Image Upload", filebox3)
|
||||||
|
create button1.make ("Update")
|
||||||
|
|
||||||
Precursor
|
Precursor
|
||||||
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", "File Upload Demo"))
|
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", "File Upload Demo"))
|
||||||
create form.make
|
|
||||||
--File
|
--File
|
||||||
create filebox.make
|
|
||||||
filebox.set_upload_function (agent upload_file)
|
filebox.set_upload_function (agent upload_file)
|
||||||
filebox.set_upload_done_event (agent submit_form)
|
filebox.set_upload_done_event (agent submit_form)
|
||||||
create n1_container.make ("File Upload", filebox)
|
|
||||||
n1_container.add_validator (create {WSF_FILESIZE_VALIDATOR}.make (10000000, "File must be smaller than 10MB"))
|
n1_container.add_validator (create {WSF_FILESIZE_VALIDATOR}.make (10000000, "File must be smaller than 10MB"))
|
||||||
form.add_control (n1_container)
|
form.add_control (n1_container)
|
||||||
--File
|
--File
|
||||||
create filebox2.make
|
|
||||||
filebox2.set_upload_function (agent upload_file)
|
filebox2.set_upload_function (agent upload_file)
|
||||||
create n2_container.make ("Auto start Upload", filebox2)
|
|
||||||
filebox2.set_change_event (agent
|
filebox2.set_change_event (agent
|
||||||
do
|
do
|
||||||
n1_container.validate
|
n1_container.validate
|
||||||
@@ -45,15 +50,13 @@ feature -- Implementation
|
|||||||
n2_container.add_validator (create {WSF_FILESIZE_VALIDATOR}.make (10000000, "File must be smaller than 10MB"))
|
n2_container.add_validator (create {WSF_FILESIZE_VALIDATOR}.make (10000000, "File must be smaller than 10MB"))
|
||||||
form.add_control (n2_container)
|
form.add_control (n2_container)
|
||||||
--Image
|
--Image
|
||||||
create filebox3.make_with_image_preview
|
|
||||||
filebox3.set_upload_function (agent upload_file)
|
filebox3.set_upload_function (agent upload_file)
|
||||||
filebox3.set_upload_done_event (agent submit_form)
|
filebox3.set_upload_done_event (agent submit_form)
|
||||||
create n3_container.make ("Image Upload", filebox3)
|
|
||||||
n3_container.add_validator (create {WSF_FILESIZE_VALIDATOR}.make (10000000, "File must be smaller than 10MB"))
|
n3_container.add_validator (create {WSF_FILESIZE_VALIDATOR}.make (10000000, "File must be smaller than 10MB"))
|
||||||
form.add_control (n3_container)
|
form.add_control (n3_container)
|
||||||
|
|
||||||
--Button 1
|
--Button 1
|
||||||
create button1.make ("Update")
|
|
||||||
button1.set_click_event (agent submit_form)
|
button1.set_click_event (agent submit_form)
|
||||||
button1.add_class ("col-lg-offset-2")
|
button1.add_class ("col-lg-offset-2")
|
||||||
form.add_control (button1)
|
form.add_control (button1)
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
<setting name="concurrency" value="scoop"/>
|
<setting name="concurrency" value="scoop"/>
|
||||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||||
<library name="ewsgi" location="..\..\library\server\ewsgi\ewsgi-safe.ecf"/>
|
<library name="ewsgi" location="..\..\library\server\ewsgi\ewsgi-safe.ecf"/>
|
||||||
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/>
|
|
||||||
<library name="vision2" location="$ISE_LIBRARY\library\vision2\vision2-safe.ecf"/>
|
<library name="vision2" location="$ISE_LIBRARY\library\vision2\vision2-safe.ecf"/>
|
||||||
<library name="web_browser" location="$ISE_LIBRARY\library\web_browser\web_browser-safe.ecf" readonly="false"/>
|
<library name="web_browser" location="$ISE_LIBRARY\library\web_browser\web_browser-safe.ecf" readonly="false"/>
|
||||||
<library name="wsf" location="..\..\library\server\wsf\wsf-safe.ecf"/>
|
<library name="wsf" location="..\..\library\server\wsf\wsf-safe.ecf"/>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ feature -- Execution
|
|||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
on_launched_action: detachable separate PROCEDURE [ANY, TUPLE]
|
on_launched_action: detachable separate PROCEDURE [TUPLE]
|
||||||
|
|
||||||
set_on_launched_action (act: like on_launched_action)
|
set_on_launched_action (act: like on_launched_action)
|
||||||
do
|
do
|
||||||
|
|||||||
@@ -207,6 +207,8 @@ feature -- Output
|
|||||||
|
|
||||||
put_character_noexception (c: CHARACTER)
|
put_character_noexception (c: CHARACTER)
|
||||||
-- Write character `c' to socket.
|
-- Write character `c' to socket.
|
||||||
|
require
|
||||||
|
extendible: extendible
|
||||||
do
|
do
|
||||||
socket_buffer.put_character (c, 0)
|
socket_buffer.put_character (c, 0)
|
||||||
put_managed_pointer_noexception (socket_buffer, 0, character_8_bytes)
|
put_managed_pointer_noexception (socket_buffer, 0, character_8_bytes)
|
||||||
@@ -224,6 +226,8 @@ feature -- Output
|
|||||||
|
|
||||||
put_readable_string_8 (s: READABLE_STRING_8)
|
put_readable_string_8 (s: READABLE_STRING_8)
|
||||||
-- Write readable string `s' to socket.
|
-- Write readable string `s' to socket.
|
||||||
|
require
|
||||||
|
extendible: extendible
|
||||||
local
|
local
|
||||||
ext: C_STRING
|
ext: C_STRING
|
||||||
do
|
do
|
||||||
@@ -243,6 +247,27 @@ feature -- Status report
|
|||||||
Result := last_string.count = 1
|
Result := last_string.count = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
set_bytes_sent (nb: INTEGER)
|
||||||
|
-- Set `bytes_sent` to `nb`;
|
||||||
|
do
|
||||||
|
bytes_sent := nb
|
||||||
|
end
|
||||||
|
|
||||||
|
report_error (m: READABLE_STRING_8)
|
||||||
|
-- Report error, and set `socket_error` to `m`.
|
||||||
|
do
|
||||||
|
socket_error := m
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Extension
|
||||||
|
|
||||||
|
socket: HTTP_STREAM_SOCKET
|
||||||
|
-- Associated socket.
|
||||||
|
do
|
||||||
|
Result := Current
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
note
|
note
|
||||||
copyright: "2011-2016, 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)"
|
||||||
|
|||||||
@@ -8,6 +8,75 @@ note
|
|||||||
deferred class
|
deferred class
|
||||||
HTTP_STREAM_SOCKET_EXT
|
HTTP_STREAM_SOCKET_EXT
|
||||||
|
|
||||||
feature {NONE} -- No-Exception network operation
|
feature -- Extension
|
||||||
|
|
||||||
|
socket: HTTP_STREAM_SOCKET
|
||||||
|
-- Associated socket.
|
||||||
|
-- Used to extend HTTP_STREAM_SOCKET with Current interface.
|
||||||
|
deferred
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- No-Exception network operation
|
||||||
|
|
||||||
|
put_file_content_with_timeout (a_file: FILE; a_offset: INTEGER; a_byte_count: INTEGER; a_timeout: INTEGER)
|
||||||
|
-- Send `a_count' bytes from the content of file `a_file' starting at offset `a_offset'.
|
||||||
|
-- When relevant, use the `a_timeout` to wait on completion (if a_timeout < 0, ignored)
|
||||||
|
require
|
||||||
|
a_file_closed_or_openread: a_file.exists and then (a_file.is_access_readable or a_file.is_closed)
|
||||||
|
byte_count_positive: a_byte_count > 0
|
||||||
|
extendible: socket.extendible
|
||||||
|
local
|
||||||
|
l_close_needed: BOOLEAN
|
||||||
|
l_bytes_sent: INTEGER
|
||||||
|
cs: C_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
|
||||||
|
create cs.make (a_file.path.name)
|
||||||
|
l_bytes_sent := c_sendfile (socket.descriptor, a_file.file_pointer, a_offset, a_byte_count, a_timeout)
|
||||||
|
if l_bytes_sent < 0 then
|
||||||
|
socket.report_error ("Network error: sendfile")
|
||||||
|
end
|
||||||
|
socket.set_bytes_sent (l_bytes_sent)
|
||||||
|
if l_close_needed then
|
||||||
|
a_file.close
|
||||||
|
end
|
||||||
|
end
|
||||||
|
ensure
|
||||||
|
bytes_sent_updated: not socket.was_error implies (0 <= socket.bytes_sent and socket.bytes_sent <= a_byte_count)
|
||||||
|
end
|
||||||
|
|
||||||
|
put_file_content (a_file: FILE; a_offset: INTEGER; a_byte_count: INTEGER)
|
||||||
|
-- Send `a_count' bytes from the content of file `a_file' starting at offset `a_offset'.
|
||||||
|
-- When relevant, use the `a_timeout` to wait on completion (if a_timeout < 0, ignored)
|
||||||
|
do
|
||||||
|
put_file_content_with_timeout (a_file, a_offset, a_byte_count, -1)
|
||||||
|
end
|
||||||
|
|
||||||
|
feature {NONE} -- External
|
||||||
|
|
||||||
|
c_sendfile (a_fd: INTEGER; fp: POINTER; a_offset: INTEGER; len: INTEGER; a_timeout: INTEGER): INTEGER
|
||||||
|
-- External routine to write file content from `fp` of
|
||||||
|
-- length `len' to socket `a_fd'
|
||||||
|
-- note: On Windows, due to asynchronous potential behavior, wait for completion using `timeout` value.
|
||||||
|
-- EIF_INTEGER c_sendfile_noexception(EIF_INTEGER out_fd, FILE* f, EIF_INTEGER offset, EIF_INTEGER length, EIF_INTEGER timeout).
|
||||||
|
external
|
||||||
|
"C blocking"
|
||||||
|
end
|
||||||
|
|
||||||
|
note
|
||||||
|
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)"
|
||||||
|
source: "[
|
||||||
|
Eiffel Software
|
||||||
|
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||||
|
Telephone 805-685-1006, Fax 805-685-6869
|
||||||
|
Website http://www.eiffel.com
|
||||||
|
Customer support http://support.eiffel.com
|
||||||
|
]"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -26,28 +26,22 @@ feature -- Initialization
|
|||||||
valid_port: a_port >= 0
|
valid_port: a_port >= 0
|
||||||
do
|
do
|
||||||
make
|
make
|
||||||
set_address (create {like address_type}.make_from_address_and_port (a_address, a_port))
|
socket.set_address (create {like socket.address_type}.make_from_address_and_port (a_address, a_port))
|
||||||
bind
|
socket.bind
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Basic operation
|
feature -- Extension
|
||||||
|
|
||||||
bind
|
socket: HTTP_STREAM_SOCKET
|
||||||
|
-- Associated socket.
|
||||||
|
-- Used to extend HTTP_STREAM_SOCKET with Current interface.
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature {NONE} -- Externals: socket option levels
|
||||||
|
|
||||||
set_address (addr: detachable like address_type)
|
level_sol_socket: INTEGER_32
|
||||||
deferred
|
-- SOL_SOCKET level of options
|
||||||
end
|
|
||||||
|
|
||||||
address_type: NETWORK_SOCKET_ADDRESS
|
|
||||||
deferred
|
|
||||||
end
|
|
||||||
|
|
||||||
descriptor: INTEGER
|
|
||||||
-- Socket descriptor of current socket
|
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -59,7 +53,7 @@ feature -- Socket Recv and Send timeout.
|
|||||||
require
|
require
|
||||||
positive_timeout: a_timeout_seconds >= 0
|
positive_timeout: a_timeout_seconds >= 0
|
||||||
do
|
do
|
||||||
c_set_sock_recv_timeout (descriptor, level_sol_socket, a_timeout_seconds)
|
c_set_sock_recv_timeout (socket.descriptor, level_sol_socket, a_timeout_seconds)
|
||||||
end
|
end
|
||||||
|
|
||||||
set_send_timeout (a_timeout_seconds: INTEGER)
|
set_send_timeout (a_timeout_seconds: INTEGER)
|
||||||
@@ -68,16 +62,77 @@ feature -- Socket Recv and Send timeout.
|
|||||||
require
|
require
|
||||||
positive_timeout: a_timeout_seconds >= 0
|
positive_timeout: a_timeout_seconds >= 0
|
||||||
do
|
do
|
||||||
c_set_sock_send_timeout (descriptor, level_sol_socket, a_timeout_seconds)
|
c_set_sock_send_timeout (socket.descriptor, level_sol_socket, a_timeout_seconds)
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Output
|
||||||
|
|
||||||
|
put_file_content_with_timeout (a_file: FILE; a_offset: INTEGER; a_byte_count: INTEGER; a_timeout_ms: INTEGER)
|
||||||
|
-- Send `a_count' bytes from the content of file `a_file' starting at offset `a_offset'.
|
||||||
|
-- When relevant, use the `a_timeout_ms` to wait on completion (if a_timeout < 0, ignored)
|
||||||
|
require
|
||||||
|
a_file_closed_or_openread: a_file.exists and then (a_file.is_access_readable or a_file.is_closed)
|
||||||
|
byte_count_positive: a_byte_count > 0
|
||||||
|
extendible: socket.extendible
|
||||||
|
local
|
||||||
|
l_close_needed: BOOLEAN
|
||||||
|
l_remain: INTEGER
|
||||||
|
l_done: BOOLEAN
|
||||||
|
s: STRING
|
||||||
|
l_bytes_sent: INTEGER
|
||||||
|
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
|
||||||
|
if a_offset > 0 then
|
||||||
|
a_file.move (a_offset)
|
||||||
|
end
|
||||||
|
from
|
||||||
|
l_remain := a_byte_count
|
||||||
|
l_done := False
|
||||||
|
until
|
||||||
|
a_file.exhausted or l_done
|
||||||
|
loop
|
||||||
|
a_file.read_stream (l_remain.min (4_096))
|
||||||
|
s := a_file.last_string
|
||||||
|
if s.is_empty then
|
||||||
|
-- File error?
|
||||||
|
l_done := True
|
||||||
|
else
|
||||||
|
socket.put_string_8_noexception (s)
|
||||||
|
l_bytes_sent := l_bytes_sent + socket.bytes_sent
|
||||||
|
l_remain := l_remain - s.count
|
||||||
|
check l_remain >= 0 end
|
||||||
|
l_done := l_remain = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
socket.set_bytes_sent (l_bytes_sent)
|
||||||
|
if l_close_needed then
|
||||||
|
a_file.close
|
||||||
|
end
|
||||||
|
end
|
||||||
|
ensure
|
||||||
|
bytes_sent_updated: not socket.was_error implies (0 <= socket.bytes_sent and socket.bytes_sent <= a_byte_count)
|
||||||
|
end
|
||||||
|
|
||||||
|
put_file_content (a_file: FILE; a_offset: INTEGER; a_byte_count: INTEGER)
|
||||||
|
-- Send `a_count' bytes from the content of file `a_file' starting at offset `a_offset'.
|
||||||
|
require
|
||||||
|
a_file_closed_or_openread: a_file.exists and then (a_file.is_access_readable or a_file.is_closed)
|
||||||
|
byte_count_positive: a_byte_count > 0
|
||||||
|
extendible: socket.extendible
|
||||||
|
do
|
||||||
|
put_file_content_with_timeout (a_file, a_offset, a_byte_count, -1)
|
||||||
|
ensure
|
||||||
|
bytes_sent_updated: not socket.was_error implies (0 <= socket.bytes_sent and socket.bytes_sent <= a_byte_count)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {NONE} -- Externals
|
feature {NONE} -- Externals
|
||||||
|
|
||||||
level_sol_socket: INTEGER
|
|
||||||
-- SOL_SOCKET level of options
|
|
||||||
deferred
|
|
||||||
end
|
|
||||||
|
|
||||||
c_set_sock_recv_timeout (a_fd, a_level: INTEGER; a_timeout_seconds: INTEGER)
|
c_set_sock_recv_timeout (a_fd, a_level: INTEGER; a_timeout_seconds: INTEGER)
|
||||||
-- C routine to set socket option `SO_RCVTIMEO' with `a_timeout_seconds' seconds.
|
-- C routine to set socket option `SO_RCVTIMEO' with `a_timeout_seconds' seconds.
|
||||||
external
|
external
|
||||||
@@ -157,4 +212,14 @@ feature {NONE} -- No-Exception network operation
|
|||||||
]"
|
]"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
note
|
||||||
|
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)"
|
||||||
|
source: "[
|
||||||
|
Eiffel Software
|
||||||
|
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||||
|
Telephone 805-685-1006, Fax 805-685-6869
|
||||||
|
Website http://www.eiffel.com
|
||||||
|
Customer support http://support.eiffel.com
|
||||||
|
]"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ class
|
|||||||
|
|
||||||
inherit
|
inherit
|
||||||
WGI_OUTPUT_STREAM
|
WGI_OUTPUT_STREAM
|
||||||
|
redefine
|
||||||
|
put_file_content
|
||||||
|
end
|
||||||
|
|
||||||
HTTP_STATUS_CODE_MESSAGES
|
HTTP_STATUS_CODE_MESSAGES
|
||||||
export
|
export
|
||||||
@@ -94,6 +97,18 @@ feature -- Output
|
|||||||
last_target_call_succeed := not target.was_error
|
last_target_call_succeed := not target.was_error
|
||||||
end
|
end
|
||||||
|
|
||||||
|
put_file_content (a_file: FILE; a_offset: INTEGER; a_byte_count: INTEGER)
|
||||||
|
-- Send `a_byte_count' bytes from the content of file `a_file' starting at offset `a_offset'.
|
||||||
|
do
|
||||||
|
if a_byte_count > 500_000 then
|
||||||
|
last_target_call_succeed := False
|
||||||
|
target.put_file_content (a_file, a_offset, a_byte_count)
|
||||||
|
last_target_call_succeed := not target.was_error
|
||||||
|
else
|
||||||
|
Precursor (a_file, a_offset, a_byte_count)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Status report
|
feature -- Status report
|
||||||
|
|
||||||
is_available: BOOLEAN
|
is_available: BOOLEAN
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<setting name="concurrency" value="scoop"/>
|
<setting name="concurrency" value="scoop"/>
|
||||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||||
<library name="ewsgi" location="..\ewsgi\ewsgi.ecf"/>
|
<library name="ewsgi" location="..\ewsgi\ewsgi.ecf"/>
|
||||||
<library name="http" location="..\..\network\protocol\http\http.ecf"/>
|
<library name="http" location="..\..\..\..\network\protocol\http\http.ecf"/>
|
||||||
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
|
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
|
||||||
<library name="uuid" location="$ISE_LIBRARY\library\uuid\uuid.ecf"/>
|
<library name="uuid" location="$ISE_LIBRARY\library\uuid\uuid.ecf"/>
|
||||||
<library name="wsf" location="wsf.ecf"/>
|
<library name="wsf" location="wsf.ecf"/>
|
||||||
|
|||||||
@@ -29,21 +29,29 @@ inherit
|
|||||||
feature {NONE} -- Initialize
|
feature {NONE} -- Initialize
|
||||||
|
|
||||||
initialize
|
initialize
|
||||||
|
do
|
||||||
|
create_filtered_router
|
||||||
|
initialize_filtered_router
|
||||||
|
end
|
||||||
|
|
||||||
|
create_filtered_router
|
||||||
|
-- Create `router` and `filter`.
|
||||||
|
do
|
||||||
|
create_router
|
||||||
|
create_filter
|
||||||
|
end
|
||||||
|
|
||||||
|
initialize_filtered_router
|
||||||
|
-- Initialize `router` and `filter`.
|
||||||
local
|
local
|
||||||
f: like filter
|
f: like filter
|
||||||
do
|
do
|
||||||
Precursor {WSF_ROUTED_EXECUTION}
|
initialize_router
|
||||||
Precursor {WSF_FILTERED_EXECUTION}
|
initialize_filter
|
||||||
|
|
||||||
-- Current is a WSF_FILTER as well in order to call the router
|
-- Current is a WSF_FILTER as well in order to call the router
|
||||||
-- let's add Current at the end of the filter chain.
|
-- let's add Current at the end of the filter chain.
|
||||||
from
|
append_filter (Current)
|
||||||
f := filter
|
|
||||||
until
|
|
||||||
not attached f.next as l_next
|
|
||||||
loop
|
|
||||||
f := l_next
|
|
||||||
end
|
|
||||||
f.set_next (Current)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Execute Filter
|
feature -- Execute Filter
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
<library name="default_cgi" location="..\library\server\wsf\default\cgi-safe.ecf" readonly="false"/>
|
<library name="default_cgi" location="..\library\server\wsf\default\cgi-safe.ecf" readonly="false"/>
|
||||||
<library name="default_libfcgi" location="..\library\server\wsf\default\libfcgi-safe.ecf" readonly="false"/>
|
<library name="default_libfcgi" location="..\library\server\wsf\default\libfcgi-safe.ecf" readonly="false"/>
|
||||||
<library name="default_openshift" location="..\library\server\wsf\default\openshift-safe.ecf" readonly="false"/>
|
<library name="default_openshift" location="..\library\server\wsf\default\openshift-safe.ecf" readonly="false"/>
|
||||||
<library name="demo-1" location="..\library\security\openid\consumer\demo\demo-safe.ecf" readonly="false"/>
|
|
||||||
<library name="encoder" location="..\library\text\encoder\encoder-safe.ecf" readonly="false"/>
|
<library name="encoder" location="..\library\text\encoder\encoder-safe.ecf" readonly="false"/>
|
||||||
<library name="error" location="..\library\utility\general\error\error-safe.ecf" readonly="false"/>
|
<library name="error" location="..\library\utility\general\error\error-safe.ecf" readonly="false"/>
|
||||||
<library name="ewsgi" location="..\library\server\ewsgi\ewsgi-safe.ecf" readonly="false"/>
|
<library name="ewsgi" location="..\library\server\ewsgi\ewsgi-safe.ecf" readonly="false"/>
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
<library name="default_libfcgi" location="..\library\server\wsf\default\libfcgi-safe.ecf" readonly="false"/>
|
<library name="default_libfcgi" location="..\library\server\wsf\default\libfcgi-safe.ecf" readonly="false"/>
|
||||||
<library name="default_openshift" location="..\library\server\wsf\default\openshift-safe.ecf" readonly="false"/>
|
<library name="default_openshift" location="..\library\server\wsf\default\openshift-safe.ecf" readonly="false"/>
|
||||||
<library name="default_standalone" location="..\library\server\wsf\default\standalone-safe.ecf" readonly="false"/>
|
<library name="default_standalone" location="..\library\server\wsf\default\standalone-safe.ecf" readonly="false"/>
|
||||||
<library name="demo-1" location="..\library\security\openid\consumer\demo\demo-safe.ecf" readonly="false"/>
|
|
||||||
<library name="encoder" location="..\library\text\encoder\encoder-safe.ecf" readonly="false"/>
|
<library name="encoder" location="..\library\text\encoder\encoder-safe.ecf" readonly="false"/>
|
||||||
<library name="error" location="..\library\utility\general\error\error-safe.ecf" readonly="false"/>
|
<library name="error" location="..\library\utility\general\error\error-safe.ecf" readonly="false"/>
|
||||||
<library name="ewsgi" location="..\library\server\ewsgi\ewsgi-safe.ecf" readonly="false"/>
|
<library name="ewsgi" location="..\library\server\ewsgi\ewsgi-safe.ecf" readonly="false"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user