Implemented WSF_RESPONSE.put_error (...) and related

Added WSF_RESPONSE.put_character
Renamed  WGI_OUTPUT_STREAM.put_character_8 as put_character  to follow style of put_string  (and not put_string_8)
Refactored the WSF_DEFAULT_SERVICE_LAUNCHER
Added WSF_DEFAULT_SERVICE to be more user friendly
Splitted the wsf/default/ libraries to have wsf/connector/... and being able to handle more than one connector in the same application
This commit is contained in:
Jocelyn Fiat
2012-03-20 10:29:55 +01:00
parent 71d5dc4795
commit 8344607eb6
63 changed files with 1238 additions and 407 deletions

View File

@@ -42,7 +42,7 @@ feature -- Execution
do
if not rescued then
create req.make ((create {EXECUTION_ENVIRONMENT}).starting_environment_variables, create {WGI_CGI_INPUT_STREAM}.make, Current)
create res.make (create {WGI_CGI_OUTPUT_STREAM}.make)
create res.make (create {WGI_CGI_OUTPUT_STREAM}.make, create {WGI_CGI_ERROR_STREAM}.make)
service.execute (req, res)
else
if attached (create {EXCEPTION_MANAGER}).last_exception as e and then attached e.exception_trace as l_trace then

View File

@@ -0,0 +1,57 @@
note
description: "Summary description for WGI_CGI_ERROR_STREAM."
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
class
WGI_CGI_ERROR_STREAM
inherit
WGI_ERROR_STREAM
CONSOLE
rename
make as console_make
end
create
make
feature {NONE} -- Initialization
make
do
make_open_stdout ("stderr")
end
feature -- Error
put_error (a_message: READABLE_STRING_8)
do
put_readable_string_8 (a_message)
end
put_readable_string_8 (s: READABLE_STRING_8)
-- Write `s' at end of default output.
local
ext: C_STRING
do
if s.count > 0 then
create ext.make (s)
console_ps (file_pointer, ext.managed_data.item, s.count)
end
end
note
copyright: "2011-2011, 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

View File

@@ -20,8 +20,8 @@ feature {NONE} -- Initialization
do
service := a_service
create fcgi.make
create {WGI_LIBFCGI_INPUT_STREAM} input.make (fcgi)
create {WGI_LIBFCGI_OUTPUT_STREAM} output.make (fcgi)
create input.make (fcgi)
create output.make (fcgi)
end
feature -- Access
@@ -63,7 +63,7 @@ feature -- Execution
do
if not rescued then
create req.make (vars, a_input, Current)
create res.make (a_output)
create res.make (a_output, a_output)
service.execute (req, res)
else
if attached (create {EXCEPTION_MANAGER}).last_exception as e and then attached e.exception_trace as l_trace then
@@ -84,10 +84,10 @@ feature -- Execution
feature -- Input/Output
input: WGI_INPUT_STREAM
input: WGI_LIBFCGI_INPUT_STREAM
-- Input from client (from httpd server via FCGI)
output: WGI_OUTPUT_STREAM
output: WGI_LIBFCGI_OUTPUT_STREAM
-- Output to client (via httpd server/fcgi)
feature {NONE} -- Implementation

View File

@@ -11,6 +11,8 @@ class
inherit
WGI_OUTPUT_STREAM
WGI_ERROR_STREAM
HTTP_STATUS_CODE_MESSAGES
export
{NONE} all
@@ -68,6 +70,12 @@ feature -- Basic operation
fcgi.put_string (s)
end
put_character (c: CHARACTER_8)
-- Send `c' to http client
do
fcgi.put_string (c.out)
end
feature -- Basic operations
flush
@@ -75,6 +83,13 @@ feature -- Basic operations
do
end
feature -- Error
put_error (a_message: READABLE_STRING_8)
do
fcgi.put_error (a_message)
end
feature {NONE} -- Implementation
fcgi: FCGI

View File

@@ -8,17 +8,33 @@ class
create
make,
make_custom
make_custom,
make_with_callback,
make_custom_with_callback
feature {NONE} -- Implementation
make (a_callback: like {WGI_AGENT_SERVICE}.callback)
make (a_service: WGI_SERVICE)
-- Initialize `Current'.
do
make_custom (a_callback, Void)
make_custom (a_service, Void)
end
make_custom (a_callback: like {WGI_AGENT_SERVICE}.callback; a_base_url: detachable STRING)
make_custom (a_service: WGI_SERVICE; a_base_url: detachable STRING)
-- Initialize `Current'.
require
base_url_starts_with_slash: (a_base_url /= Void and then not a_base_url.is_empty) implies a_base_url.starts_with ("/")
do
create connector.make_with_base (a_service, a_base_url)
end
make_with_callback (a_callback: like {WGI_AGENT_SERVICE}.callback)
-- Initialize `Current'.
do
make_custom_with_callback (a_callback, Void)
end
make_custom_with_callback (a_callback: like {WGI_AGENT_SERVICE}.callback; a_base_url: detachable STRING)
-- Initialize `Current'.
require
base_url_starts_with_slash: (a_base_url /= Void and then not a_base_url.is_empty) implies a_base_url.starts_with ("/")
@@ -26,7 +42,7 @@ feature {NONE} -- Implementation
app: WGI_AGENT_SERVICE
do
create app.make (a_callback)
create connector.make_with_base (app, a_base_url)
make_custom (app, a_base_url)
end
feature -- Access
@@ -88,7 +104,7 @@ feature -- Server
end
note
copyright: "2011-2011, Eiffel Software and others"
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -119,7 +119,7 @@ feature -- Server
res: detachable WGI_NINO_RESPONSE_STREAM
do
create req.make (env, create {WGI_NINO_INPUT_STREAM}.make (a_socket), Current)
create res.make (create {WGI_NINO_OUTPUT_STREAM}.make (a_socket))
create res.make (create {WGI_NINO_OUTPUT_STREAM}.make (a_socket), Void)
req.set_meta_string_variable ("RAW_HEADER_DATA", a_headers_text)
service.execute (req, res)
res.commit

View File

@@ -10,9 +10,6 @@ class
inherit
WGI_OUTPUT_STREAM
redefine
put_character_8
end
HTTP_STATUS_CODE_MESSAGES
export
@@ -66,7 +63,7 @@ feature -- Output
target.put_readable_string_8 (s)
end
put_character_8 (c: CHARACTER_8)
put_character (c: CHARACTER_8)
do
target.put_character (c)
end
@@ -86,7 +83,7 @@ feature -- Basic operations
end
note
copyright: "2011-2011, Eiffel Software and others"
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -14,9 +14,8 @@ create
feature {NONE} -- Initialization
make (a_service: like service)
make
do
service := a_service
end
feature -- Access
@@ -27,42 +26,14 @@ feature -- Access
Version: STRING_8 = "0.1"
-- Version of Current connector
feature {NONE} -- Access
service: WGI_SERVICE
-- Gateway Service
feature -- Execution
launch
local
req: WGI_REQUEST_FROM_TABLE
res: detachable WGI_RESPONSE_STREAM
rescued: BOOLEAN
do
if not rescued then
create req.make ((create {EXECUTION_ENVIRONMENT}).starting_environment_variables, create {WGI_NULL_INPUT_STREAM}.make, Current)
create res.make (create {WGI_NULL_OUTPUT_STREAM}.make)
service.execute (req, res)
else
if attached (create {EXCEPTION_MANAGER}).last_exception as e and then attached e.exception_trace as l_trace then
if res /= Void then
if not res.status_is_set then
res.set_status_code ({HTTP_STATUS_CODE}.internal_server_error)
end
if res.message_writable then
res.put_string ("<pre>" + l_trace + "</pre>")
end
end
end
end
rescue
rescued := True
retry
end
note
copyright: "2011-2011, Eiffel Software and others"
copyright: "2011-2012, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -96,6 +96,13 @@ feature -- Header output operation
feature -- Output operation
put_character (c: CHARACTER_8)
-- Send the character `c'
require
message_writable: message_writable
deferred
end
put_string (s: READABLE_STRING_8)
-- Send the string `s'
require
@@ -115,6 +122,14 @@ feature -- Output operation
deferred
end
feature -- Error reporting
put_error (a_message: READABLE_STRING_8)
-- Report error described by `a_message'
-- This might be used by the underlying connector
deferred
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"

View File

@@ -0,0 +1,32 @@
note
description : "[
Objects that represents the error stream
]"
specification: "EWSGI/connector specification https://github.com/Eiffel-World/Eiffel-Web-Framework/wiki/EWSGI-specification"
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
deferred class
WGI_ERROR_STREAM
feature -- Output
put_error (a_message: READABLE_STRING_8)
-- Report error described by `a_message'
-- This might be used by the underlying connector
deferred
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, 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

View File

@@ -37,13 +37,12 @@ feature -- Output
end
end
put_character_8 (c: CHARACTER_8)
put_character (c: CHARACTER_8)
-- Write `c' to output stream.
--| Could be redefined for optimization
require
is_open_write: is_open_write
do
put_string (c.out)
deferred
end
feature -- Specific output

View File

@@ -17,9 +17,10 @@ create
feature {NONE} -- Initialization
make (a_output: like output)
make (a_output: like output; a_error: like error)
do
output := a_output
error := a_error
end
feature {WGI_CONNECTOR, WGI_SERVICE} -- Commit
@@ -97,6 +98,12 @@ feature -- Header output operation
feature -- Output operation
put_character (c: CHARACTER_8)
-- Send the character `c'
do
output.put_character (c)
end
put_string (s: READABLE_STRING_8)
-- Send the string `s'
do
@@ -115,11 +122,25 @@ feature -- Output operation
output.flush
end
feature -- Error reporting
put_error (a_message: READABLE_STRING_8)
-- Report error described by `a_message'
-- This might be used by the underlying connector
do
if attached error as err then
err.put_error (a_message)
end
end
feature {NONE} -- Implementation: Access
output: WGI_OUTPUT_STREAM
-- Server output channel
error: detachable WGI_ERROR_STREAM
-- Server output channel
;note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"