If the count for put_file_content is not positive (i.e <= 0), do not send anything.

Output/log more information for request handling when standalone httpd server has verbose enabled.
This commit is contained in:
2016-12-01 21:20:14 +01:00
parent 9fd53b9b1f
commit 186e5514eb
4 changed files with 33 additions and 9 deletions

View File

@@ -22,13 +22,10 @@ create
feature {NONE} -- Initialization
initialize
local
opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS
do
Precursor
--| Uncomment the following 2 lines, to read options from "ewf.ini" configuration file
-- create {WSF_SERVICE_LAUNCHER_OPTIONS_FROM_INI} opts.make_from_file ("ewf.ini")
-- import_service_options (opts)
--| Uncomment the following line, to read options from "ewf.ini" configuration file
-- import_service_options (create {WSF_SERVICE_LAUNCHER_OPTIONS_FROM_INI} opts.make_from_file ("ewf.ini"))
end
launch (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)

View File

@@ -106,7 +106,9 @@ feature -- Output operation
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)
if a_count > 0 then
output.put_file_content (f, a_offset, a_count)
end
end
flush

View File

@@ -170,6 +170,9 @@ feature -- Status change
-- Report error occurred, with optional message `m'.
do
has_error := True
if m /= Void and then is_verbose then
log (m.as_string_8, debug_level)
end
end
reset_error
@@ -313,7 +316,7 @@ feature -- Execution
is_persistent_connection_requested := False
else
if is_verbose then
log (request_header, information_level)
log_with_separation_line (request_header, information_level)
end
process_request (l_socket)
end
@@ -590,6 +593,26 @@ feature -- Output
logger_set: logger = a_logger
end
log_with_separation_line (m: STRING; a_level: INTEGER)
-- Log message `m'.
require
is_verbose: is_verbose
local
s: STRING
do
if is_verbose and (verbose_level & a_level) = a_level then
create s.make (m.count + 42)
s.append (create {STRING}.make_filled ('-', 40))
s.append_character ('%N')
s.append (m)
if attached logger as l_logger then
l_logger.log (s)
else
io.put_string (s + "%N")
end
end
end
log (m: STRING; a_level: INTEGER)
-- Log message `m'.
require

View File

@@ -389,8 +389,10 @@ feature -- Body
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)
if a_count > 0 then
wgi_response.put_file_content (f, a_offset, a_count)
increment_transfered_content_length (a_count)
end
end
feature -- Chunk body