Fixed WGI_HTTPD_REQUEST_HANDLER.process_rescue

Fixed WGI_STANDALONE_OUTPUT_STREAM.is_available
Added WGI_STANDALONE_RESPONSE_STREAM.is_persistent_connection_supported
This commit is contained in:
2015-07-02 10:50:41 +02:00
parent 78c0cd5b0d
commit 31557cfc33
4 changed files with 39 additions and 7 deletions

View File

@@ -87,6 +87,7 @@ feature -- Request processing
else
l_output.set_http_version (version)
end
res.set_is_persistent_connection_supported ({HTTPD_SERVER}.is_persistent_connection_supported)
res.set_is_persistent_connection_requested (is_persistent_connection_requested)
req.set_meta_string_variable ("RAW_HEADER_DATA", request_header)
@@ -111,22 +112,30 @@ feature -- Request processing
end
end
process_rescue (res: detachable WGI_RESPONSE)
local
s: STRING
do
if attached (create {EXCEPTION_MANAGER}).last_exception as e and then attached e.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, Void)
end
create s.make_empty
s.append ("<pre>")
s.append (html_encoder.encoded_string (l_trace))
s.append ("</pre>")
if not res.header_committed then
res.put_header_text ("Content-Type: text/html%R%NContent-Length: " + s.count.out + "%R%N%R%N")
end
if res.message_writable then
res.put_string ("<pre>")
res.put_string (html_encoder.encoded_string (l_trace))
res.put_string ("</pre>")
res.put_string (s)
end
res.push
end
end
end
end
httpd_environment (a_socket: HTTPD_STREAM_SOCKET): STRING_TABLE [READABLE_STRING_8]
local

View File

@@ -100,7 +100,7 @@ feature -- Status report
-- <Precursor>
-- for instance IO failure due to socket disconnection.
do
Result := not last_target_call_succeed
Result := last_target_call_succeed
end
is_open_write: BOOLEAN

View File

@@ -23,6 +23,9 @@ feature -- Settings
is_http_version_1_0: BOOLEAN
-- Is associated request using HTTP/1.0 ?
is_persistent_connection_supported: BOOLEAN
-- Is persistent connection supported?
is_persistent_connection_requested: BOOLEAN
-- Is persistent connection requested?
@@ -34,6 +37,12 @@ feature -- Settings change
is_http_version_1_0 := True
end
set_is_persistent_connection_supported (b: BOOLEAN)
-- Set `is_persistent_connection_supported' to `b'.
do
is_persistent_connection_supported := b
end
set_is_persistent_connection_requested (b: BOOLEAN)
-- Set `is_persistent_connection_requested' to `b'.
do
@@ -53,7 +62,7 @@ feature -- Header output operation
create s.make_from_string (a_text)
i := s.substring_index ("%NConnection:", 1)
if {HTTPD_SERVER}.is_persistent_connection_supported then
if is_persistent_connection_supported then
-- Current standalone support persistent connection.
-- If HTTP/1.1:
-- by default all connection are persistent

View File

@@ -9,6 +9,7 @@ class
inherit
WGI_FILTER_RESPONSE
redefine
set_status_code,
commit,
put_character,
put_string,
@@ -74,6 +75,19 @@ feature {NONE} -- Implementation
header_committed: header_committed
end
feature -- Status setting
set_status_code (a_code: INTEGER; a_reason_phrase: detachable READABLE_STRING_8)
-- Set response status code with custom `a_reason_phrase' if precised
-- Should be done before sending any data back to the client
do
if a_reason_phrase /= Void then
wsf_response.set_status_code_with_reason_phrase (a_code, a_reason_phrase)
else
wsf_response.set_status_code (a_code)
end
end
feature -- Status report
message_writable: BOOLEAN = True
@@ -116,7 +130,7 @@ feature -- Output operation
end
note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2015, 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