Added debug clause to detect in WSF_ROUTER.map_with_request_methods the existing conflicts with similar mapping.

Added smart handling of HEAD request.
Exported some internal features of WSF_REQUEST and WSF_RESPONSE to respectively WSF_REQUEST_EXPORTER and WSF_RESPONSE_EXPORTER
This commit is contained in:
Jocelyn Fiat
2012-11-26 22:58:48 +01:00
parent bdee22f647
commit 125d44ff67
9 changed files with 213 additions and 19 deletions

View File

@@ -0,0 +1,81 @@
note
description: "[
This class is a wrapper on a standard WSF_RESPONSE
It is used to compute a HEAD request based on a GET request method handling
]"
date: "$Date$"
revision: "$Revision$"
class
WSF_HEAD_RESPONSE_WRAPPER
inherit
WSF_RESPONSE
redefine
put_character,
put_string,
put_substring,
put_chunk,
put_chunk_end
end
WSF_RESPONSE_EXPORTER
create
make_from_response
feature {NONE} -- Initialization
make_from_response (res: WSF_RESPONSE)
do
wsf_response := res
make_from_wgi (res.wgi_response)
end
feature {WSF_RESPONSE} -- Access
wsf_response: WSF_RESPONSE
-- Wrapped response
feature -- Output operation
put_character (c: CHARACTER_8)
do
-- HEAD has no content
end
put_string (s: READABLE_STRING_8)
do
-- HEAD has no content
end
put_substring (s: READABLE_STRING_8; a_begin_index, a_end_index: INTEGER)
do
-- HEAD has no content
end
put_chunk (s: READABLE_STRING_8; a_extension: detachable READABLE_STRING_8)
do
-- HEAD has no content
end
put_chunk_end
do
-- HEAD has no content
end
invariant
transfered_content_length_is_zero: transfered_content_length = 0
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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

@@ -39,6 +39,7 @@ feature {NONE} -- Initialization
tb: like meta_variables_table
do
wgi_request := r
create string_equality_tester
if attached r.meta_variables as l_vars then
create tb.make_with_key_tester (l_vars.count, string_equality_tester)
@@ -55,21 +56,26 @@ feature {NONE} -- Initialization
create error_handler.make
create uploaded_files_table.make_with_key_tester (0, string_equality_tester)
set_raw_input_data_recorded (False)
create {STRING_32} empty_string.make_empty
create {IMMUTABLE_STRING_32} empty_string.make_empty
create execution_variables_table.make_with_key_tester (0, string_equality_tester)
execution_variables_table.compare_objects
initialize
analyze
ensure
wgi_request_set: wgi_request = r
request_method_set: request_method.same_string (r.request_method)
end
initialize
-- Specific initialization
local
s8: detachable READABLE_STRING_8
req: WGI_REQUEST
do
init_mime_handlers
req := wgi_request
--| Content-Length
if attached content_length as s and then s.is_natural_64 then
@@ -79,18 +85,21 @@ feature {NONE} -- Initialization
end
-- Content-Type
s8 := wgi_request.content_type
s8 := req.content_type
if s8 /= Void then
create content_type.make_from_string (s8)
else
content_type := Void
end
--| Request Methods
request_method := req.request_method
--| PATH_INFO
path_info := raw_url_encoder.decoded_string (wgi_request.path_info)
path_info := raw_url_encoder.decoded_string (req.path_info)
--| PATH_TRANSLATED
s8 := wgi_request.path_translated
s8 := req.path_translated
if s8 /= Void then
path_translated := raw_url_encoder.decoded_string (s8)
end
@@ -211,6 +220,15 @@ feature -- Eiffel WGI access
Result := wgi_request.wgi_connector
end
feature {WSF_REQUEST_EXPORTER} -- Override value
set_request_method (a_request_method: like request_method)
-- Set `request_method' to `a_request_method'
-- note: this is mainly to have smart handling of HEAD request
do
request_method := a_request_method
end
feature {NONE} -- Access: global variable
items_table: HASH_TABLE_EX [WSF_VALUE, READABLE_STRING_GENERAL]
@@ -679,9 +697,6 @@ feature -- Access: CGI meta parameters - 1.1
-- This variable is specific to requests made with HTTP.
--
-- Servers MUST provide this metavariable to scripts.
do
Result := wgi_request.request_method
end
script_name: READABLE_STRING_8
-- The SCRIPT_NAME metavariable is set to a URL path that could

View File

@@ -0,0 +1,20 @@
note
description: "Objects that can access low level features of {WSF_REQUEST}"
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_REQUEST_EXPORTER
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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

@@ -31,6 +31,8 @@ feature {NONE} -- Initialization
wgi_response := r
end
feature {WSF_RESPONSE_EXPORTER} -- Properties
wgi_response: WGI_RESPONSE
-- Associated WGI_RESPONSE

View File

@@ -0,0 +1,19 @@
note
description: "Objects that can access low level features of {WSF_RESPONSE}"
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_RESPONSE_EXPORTER
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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