This commit is contained in:
@@ -63,7 +63,6 @@ feature -- Basic operation
|
|||||||
|
|
||||||
put (a_path: READABLE_STRING_8; a_ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT; data: detachable READABLE_STRING_8): HTTP_CLIENT_RESPONSE
|
put (a_path: READABLE_STRING_8; a_ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT; data: detachable READABLE_STRING_8): HTTP_CLIENT_RESPONSE
|
||||||
local
|
local
|
||||||
req: HTTP_CLIENT_REQUEST
|
|
||||||
ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT
|
ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT
|
||||||
f: detachable RAW_FILE
|
f: detachable RAW_FILE
|
||||||
l_data: detachable READABLE_STRING_8
|
l_data: detachable READABLE_STRING_8
|
||||||
|
|||||||
@@ -68,10 +68,6 @@ feature -- Basic operations
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Constants
|
|
||||||
|
|
||||||
Date_time_format: STRING = "[0]dd/[0]mm/yyyy [0]hh:[0]mi:[0]ss"
|
|
||||||
|
|
||||||
note
|
note
|
||||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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)"
|
||||||
|
|||||||
@@ -116,6 +116,41 @@ feature -- Access: Uploaded File
|
|||||||
|
|
||||||
feature -- Conversion
|
feature -- Conversion
|
||||||
|
|
||||||
|
append_content_to_string (a_target: STRING)
|
||||||
|
-- Append the content of the uploaded file to `a_target'.
|
||||||
|
local
|
||||||
|
f: RAW_FILE
|
||||||
|
s: STRING
|
||||||
|
done: BOOLEAN
|
||||||
|
retried: BOOLEAN
|
||||||
|
do
|
||||||
|
if not retried and attached tmp_name as fn then
|
||||||
|
create f.make_with_name (fn)
|
||||||
|
if f.exists then
|
||||||
|
f.open_read
|
||||||
|
from
|
||||||
|
until
|
||||||
|
done
|
||||||
|
loop
|
||||||
|
f.read_stream_thread_aware (1_024)
|
||||||
|
s := f.last_string
|
||||||
|
if s.is_empty then
|
||||||
|
done := True
|
||||||
|
else
|
||||||
|
a_target.append (s)
|
||||||
|
done := f.exhausted or f.end_of_file
|
||||||
|
end
|
||||||
|
end
|
||||||
|
f.close
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
retried := True
|
||||||
|
retry
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Implementation
|
||||||
|
|
||||||
safe_filename: STRING
|
safe_filename: STRING
|
||||||
local
|
local
|
||||||
fn: like filename
|
fn: like filename
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ feature {NONE} -- Initialization
|
|||||||
do
|
do
|
||||||
router := a_router
|
router := a_router
|
||||||
make (req)
|
make (req)
|
||||||
|
set_suggestion_only_method (True)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
@@ -36,6 +37,9 @@ feature -- Settings
|
|||||||
documentation_included: BOOLEAN
|
documentation_included: BOOLEAN
|
||||||
-- Include self-documentation from `router' in the response?
|
-- Include self-documentation from `router' in the response?
|
||||||
|
|
||||||
|
suggestion_only_method: BOOLEAN
|
||||||
|
-- Display only suggestion for `req' method ?
|
||||||
|
|
||||||
feature -- Change
|
feature -- Change
|
||||||
|
|
||||||
set_documentation_included (b: BOOLEAN)
|
set_documentation_included (b: BOOLEAN)
|
||||||
@@ -43,6 +47,14 @@ feature -- Change
|
|||||||
documentation_included := b
|
documentation_included := b
|
||||||
end
|
end
|
||||||
|
|
||||||
|
set_suggestion_only_method (b: BOOLEAN)
|
||||||
|
-- Set `suggestion_only_method' to `b'
|
||||||
|
do
|
||||||
|
suggestion_only_method := b
|
||||||
|
ensure
|
||||||
|
suggestion_only_method_set: suggestion_only_method = b
|
||||||
|
end
|
||||||
|
|
||||||
feature {WSF_RESPONSE} -- Output
|
feature {WSF_RESPONSE} -- Output
|
||||||
|
|
||||||
send_to (res: WSF_RESPONSE)
|
send_to (res: WSF_RESPONSE)
|
||||||
@@ -138,10 +150,14 @@ feature {NONE} -- Implementation
|
|||||||
not_found_message (req: WSF_REQUEST): WSF_NOT_FOUND_RESPONSE
|
not_found_message (req: WSF_REQUEST): WSF_NOT_FOUND_RESPONSE
|
||||||
local
|
local
|
||||||
vis: WSF_ROUTER_AGENT_ITERATOR
|
vis: WSF_ROUTER_AGENT_ITERATOR
|
||||||
|
l_method: detachable READABLE_STRING_8
|
||||||
do
|
do
|
||||||
Result := Precursor (req)
|
Result := Precursor (req)
|
||||||
if documentation_included then
|
if documentation_included then
|
||||||
create vis
|
create vis
|
||||||
|
if suggestion_only_method then
|
||||||
|
l_method := req.request_method
|
||||||
|
end
|
||||||
vis.on_item_actions.extend (agent (i: WSF_ROUTER_ITEM; r: WSF_NOT_FOUND_RESPONSE; m: detachable READABLE_STRING_8)
|
vis.on_item_actions.extend (agent (i: WSF_ROUTER_ITEM; r: WSF_NOT_FOUND_RESPONSE; m: detachable READABLE_STRING_8)
|
||||||
local
|
local
|
||||||
l_is_hidden: BOOLEAN
|
l_is_hidden: BOOLEAN
|
||||||
@@ -174,7 +190,7 @@ feature {NONE} -- Implementation
|
|||||||
r.add_suggested_text (s, Void)
|
r.add_suggested_text (s, Void)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end (?, Result, req.request_method))
|
end (?, Result, l_method))
|
||||||
vis.process_router (router)
|
vis.process_router (router)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -136,11 +136,11 @@ feature {WSF_RESPONSE} -- Output
|
|||||||
s.append (
|
s.append (
|
||||||
"[
|
"[
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
div#header {color: #fff; background-color: #000; padding: 20px; width: 100%; text-align: center; font-size: 2em; font-weight: bold;}
|
div#header {color: #fff; background-color: #000; padding: 20px; text-align: center; font-size: 2em; font-weight: bold;}
|
||||||
div#message { margin: 40px; width: 100%; text-align: center; font-size: 1.5em; }
|
div#message { margin: 40px; text-align: center; font-size: 1.5em; }
|
||||||
div#suggestions { margin: auto; width: 60%;}
|
div#suggestions { margin: auto; width: 60%;}
|
||||||
div#suggestions ul { }
|
div#suggestions ul { }
|
||||||
div#footer {color: #999; background-color: #eee; padding: 10px; width: 100%; text-align: center; }
|
div#footer {color: #999; background-color: #eee; padding: 10px; text-align: center; }
|
||||||
div#logo { float: right; margin: 20px; width: 60px height: auto; font-size: 0.8em; text-align: center; }
|
div#logo { float: right; margin: 20px; width: 60px height: auto; font-size: 0.8em; text-align: center; }
|
||||||
div#logo div.outter { padding: 6px; width: 60px; border: solid 3px #500; background-color: #b00;}
|
div#logo div.outter { padding: 6px; width: 60px; border: solid 3px #500; background-color: #b00;}
|
||||||
div#logo div.outter div.inner1 { display: block; margin: 10px 15px; width: 30px; height: 50px; color: #fff; background-color: #fff; border: solid 2px #900; }
|
div#logo div.outter div.inner1 { display: block; margin: 10px 15px; width: 30px; height: 50px; color: #fff; background-color: #fff; border: solid 2px #900; }
|
||||||
|
|||||||
@@ -81,11 +81,11 @@ feature {WSF_RESPONSE} -- Output
|
|||||||
s.append ("</title>%N")
|
s.append ("</title>%N")
|
||||||
s.append ("[
|
s.append ("[
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
div#header {color: #fff; background-color: #000; padding: 20px; width: 100%; text-align: center; font-size: 2em; font-weight: bold;}
|
div#header {color: #fff; background-color: #000; padding: 20px; text-align: center; font-size: 2em; font-weight: bold;}
|
||||||
div#message { margin: 40px; width: 100%; text-align: center; font-size: 1.5em; }
|
div#message { margin: 40px; text-align: center; font-size: 1.5em; }
|
||||||
div#suggestions { margin: auto; width: 60%;}
|
div#suggestions { margin: auto; width: 60%;}
|
||||||
div#suggestions ul { }
|
div#suggestions ul { }
|
||||||
div#footer {color: #999; background-color: #eee; padding: 10px; width: 100%; text-align: center; }
|
div#footer {color: #999; background-color: #eee; padding: 10px; text-align: center; }
|
||||||
div#logo { float: right; margin: 20px; width: 60px height: auto; font-size: 0.8em; text-align: center; }
|
div#logo { float: right; margin: 20px; width: 60px height: auto; font-size: 0.8em; text-align: center; }
|
||||||
div#logo div.outter { padding: 6px; width: 60px; border: solid 3px #500; background-color: #b00;}
|
div#logo div.outter { padding: 6px; width: 60px; border: solid 3px #500; background-color: #b00;}
|
||||||
div#logo div.outter div.inner1 { display: block; margin: 10px 15px; width: 30px; height: 50px; color: #fff; background-color: #fff; border: solid 2px #900; }
|
div#logo div.outter div.inner1 { display: block; margin: 10px 15px; width: 30px; height: 50px; color: #fff; background-color: #fff; border: solid 2px #900; }
|
||||||
@@ -198,7 +198,7 @@ feature {WSF_RESPONSE} -- Output
|
|||||||
end
|
end
|
||||||
|
|
||||||
note
|
note
|
||||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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
|
||||||
|
|||||||
@@ -53,8 +53,6 @@ feature {WSF_RESPONSE} -- Output
|
|||||||
send_to (res: WSF_RESPONSE)
|
send_to (res: WSF_RESPONSE)
|
||||||
local
|
local
|
||||||
s: STRING
|
s: STRING
|
||||||
l_text: detachable READABLE_STRING_GENERAL
|
|
||||||
l_loc: detachable READABLE_STRING_8
|
|
||||||
h: like header
|
h: like header
|
||||||
do
|
do
|
||||||
h := header
|
h := header
|
||||||
@@ -68,9 +66,9 @@ feature {WSF_RESPONSE} -- Output
|
|||||||
s.append ("</title>%N")
|
s.append ("</title>%N")
|
||||||
s.append ("[
|
s.append ("[
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
div#header {color: #fff; background-color: #000; padding: 20px; width: 100%; text-align: center; font-size: 2em; font-weight: bold;}
|
div#header {color: #fff; background-color: #000; padding: 20px; text-align: center; font-size: 2em; font-weight: bold;}
|
||||||
div#message { margin: 40px; width: 100%; text-align: center; font-size: 1.5em; }
|
div#message { margin: 40px; text-align: center; font-size: 1.5em; }
|
||||||
div#footer {color: #999; background-color: #eee; padding: 10px; width: 100%; text-align: center; }
|
div#footer {color: #999; background-color: #eee; padding: 10px; text-align: center; }
|
||||||
div#logo { float: right; margin: 20px; width: 60px height: auto; font-size: 0.8em; text-align: center; }
|
div#logo { float: right; margin: 20px; width: 60px height: auto; font-size: 0.8em; text-align: center; }
|
||||||
div#logo div.outter { padding: 6px; width: 60px; border: solid 3px #500; background-color: #b00;}
|
div#logo div.outter { padding: 6px; width: 60px; border: solid 3px #500; background-color: #b00;}
|
||||||
div#logo div.outter div.inner1 { display: block; margin: 10px 15px; width: 30px; height: 50px; color: #fff; background-color: #fff; border: solid 2px #900; }
|
div#logo div.outter div.inner1 { display: block; margin: 10px 15px; width: 30px; height: 50px; color: #fff; background-color: #fff; border: solid 2px #900; }
|
||||||
@@ -118,7 +116,7 @@ feature {WSF_RESPONSE} -- Output
|
|||||||
|
|
||||||
note
|
note
|
||||||
|
|
||||||
copyright: "2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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
|
||||||
|
|||||||
@@ -7,45 +7,19 @@ deferred class
|
|||||||
WSF_DEFAULT_SERVICE_I [G -> WSF_SERVICE_LAUNCHER create make_and_launch end]
|
WSF_DEFAULT_SERVICE_I [G -> WSF_SERVICE_LAUNCHER create make_and_launch end]
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
WSF_SERVICE
|
WSF_LAUNCHABLE_SERVICE
|
||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
frozen make_and_launch
|
launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||||
local
|
local
|
||||||
l_launcher: G
|
l_launcher: G
|
||||||
do
|
do
|
||||||
initialize
|
create l_launcher.make_and_launch (a_service, opts)
|
||||||
create l_launcher.make_and_launch (Current, service_options)
|
|
||||||
end
|
|
||||||
|
|
||||||
initialize
|
|
||||||
-- Initialize current service
|
|
||||||
--| Could be redefine to set custom service option(s)
|
|
||||||
do
|
|
||||||
end
|
|
||||||
|
|
||||||
service_options: detachable WSF_SERVICE_LAUNCHER_OPTIONS
|
|
||||||
|
|
||||||
feature -- Default service options
|
|
||||||
|
|
||||||
set_service_option (a_name: READABLE_STRING_GENERAL; a_value: detachable ANY)
|
|
||||||
-- Set options related to WSF_DEFAULT_SERVICE
|
|
||||||
local
|
|
||||||
opts: like service_options
|
|
||||||
do
|
|
||||||
opts := service_options
|
|
||||||
if opts = Void then
|
|
||||||
create opts.make
|
|
||||||
service_options := opts
|
|
||||||
end
|
|
||||||
opts.set_option (a_name, a_value)
|
|
||||||
ensure
|
|
||||||
attached service_options as l_options and then l_options.option (a_name) = a_value
|
|
||||||
end
|
end
|
||||||
|
|
||||||
note
|
note
|
||||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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
|
||||||
|
|||||||
@@ -199,7 +199,6 @@ feature -- Access: Input
|
|||||||
local
|
local
|
||||||
l_input: WGI_INPUT_STREAM
|
l_input: WGI_INPUT_STREAM
|
||||||
n: INTEGER
|
n: INTEGER
|
||||||
s: STRING
|
|
||||||
do
|
do
|
||||||
if raw_input_data_recorded and then attached raw_input_data as d then
|
if raw_input_data_recorded and then attached raw_input_data as d then
|
||||||
buf.copy (d)
|
buf.copy (d)
|
||||||
@@ -486,6 +485,14 @@ feature -- Helpers: global variables
|
|||||||
|
|
||||||
feature -- Execution variables
|
feature -- Execution variables
|
||||||
|
|
||||||
|
has_execution_variable (a_name: READABLE_STRING_GENERAL): BOOLEAN
|
||||||
|
-- Has execution variable related to `a_name'?
|
||||||
|
require
|
||||||
|
a_name_valid: a_name /= Void and then not a_name.is_empty
|
||||||
|
do
|
||||||
|
Result := execution_variables_table.has (a_name)
|
||||||
|
end
|
||||||
|
|
||||||
execution_variable (a_name: READABLE_STRING_GENERAL): detachable ANY
|
execution_variable (a_name: READABLE_STRING_GENERAL): detachable ANY
|
||||||
-- Execution variable related to `a_name'
|
-- Execution variable related to `a_name'
|
||||||
require
|
require
|
||||||
@@ -1716,14 +1723,18 @@ feature {WSF_MIME_HANDLER} -- Temporary File handling
|
|||||||
rescued: BOOLEAN
|
rescued: BOOLEAN
|
||||||
do
|
do
|
||||||
if not rescued then
|
if not rescued then
|
||||||
|
if attached uploaded_file_path as p then
|
||||||
|
dn := p
|
||||||
|
else
|
||||||
-- FIXME: should it be configured somewhere?
|
-- FIXME: should it be configured somewhere?
|
||||||
dn := (create {EXECUTION_ENVIRONMENT}).current_working_directory
|
dn := (create {EXECUTION_ENVIRONMENT}).current_working_directory
|
||||||
|
end
|
||||||
create d.make (dn)
|
create d.make (dn)
|
||||||
if d.exists and then d.is_writable then
|
if d.exists and then d.is_writable then
|
||||||
l_safe_name := a_up_file.safe_filename
|
l_safe_name := a_up_file.safe_filename
|
||||||
from
|
from
|
||||||
create fn.make_from_string (dn)
|
create fn.make_from_string (dn)
|
||||||
bn := "tmp-" + l_safe_name
|
bn := "EWF_tmp-" + l_safe_name
|
||||||
fn.set_file_name (bn)
|
fn.set_file_name (bn)
|
||||||
create f.make (fn.string)
|
create f.make (fn.string)
|
||||||
n := 0
|
n := 0
|
||||||
@@ -1733,7 +1744,7 @@ feature {WSF_MIME_HANDLER} -- Temporary File handling
|
|||||||
loop
|
loop
|
||||||
n := n + 1
|
n := n + 1
|
||||||
fn.make_from_string (dn)
|
fn.make_from_string (dn)
|
||||||
bn := "tmp-" + n.out + "-" + l_safe_name
|
bn := "EWF_tmp-" + n.out + "-" + l_safe_name
|
||||||
fn.set_file_name (bn)
|
fn.set_file_name (bn)
|
||||||
f.make (fn.string)
|
f.make (fn.string)
|
||||||
end
|
end
|
||||||
@@ -1759,6 +1770,19 @@ feature {WSF_MIME_HANDLER} -- Temporary File handling
|
|||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature {WSF_REQUEST_EXPORTER} -- Settings
|
||||||
|
|
||||||
|
uploaded_file_path: detachable READABLE_STRING_8
|
||||||
|
-- Optional folder path used to store uploaded files
|
||||||
|
|
||||||
|
set_uploaded_file_path (p: like uploaded_file_path)
|
||||||
|
-- Set `uploaded_file_path' to `p'.
|
||||||
|
require
|
||||||
|
path_exists: p /= Void implies (create {DIRECTORY}.make (p)).exists
|
||||||
|
do
|
||||||
|
uploaded_file_path := p
|
||||||
|
end
|
||||||
|
|
||||||
feature {NONE} -- Internal value
|
feature {NONE} -- Internal value
|
||||||
|
|
||||||
internal_query_parameters_table: detachable like query_parameters_table
|
internal_query_parameters_table: detachable like query_parameters_table
|
||||||
|
|||||||
Reference in New Issue
Block a user