Uncommented code to make recognized_methods supported by the method not allowed response.

Still need to see how to use it and set the recognized methods for the application.
This commit is contained in:
Jocelyn Fiat
2013-03-27 17:10:04 +01:00
parent 01cab452d8
commit 44cb0ad98c

View File

@@ -28,7 +28,7 @@ feature {NONE} -- Initialization
create suggested_items.make (0) create suggested_items.make (0)
end end
feature -- Header feature -- Access
header: HTTP_HEADER header: HTTP_HEADER
-- Response' header -- Response' header
@@ -48,8 +48,23 @@ feature -- Header
-- Optional body -- Optional body
-- Displayed as extra content -- Displayed as extra content
recognized_methods: detachable WSF_REQUEST_METHODS
-- All methods recognized by the application
feature -- Element change feature -- Element change
set_recognized_methods (m: like recognized_methods)
-- Set `recognized_methods' to `m'
do
recognized_methods := m
end
set_default_recognized_methods
-- Set `default_recognized_methods' (defined in HTTP/1.1 specification) to `m'
do
recognized_methods := default_recognized_methods
end
set_suggested_methods (m: like suggested_methods) set_suggested_methods (m: like suggested_methods)
-- Set `suggested_methods' to `m' -- Set `suggested_methods' to `m'
do do
@@ -82,18 +97,18 @@ feature {WSF_RESPONSE} -- Output
l_text: detachable READABLE_STRING_GENERAL l_text: detachable READABLE_STRING_GENERAL
l_loc: detachable READABLE_STRING_8 l_loc: detachable READABLE_STRING_8
h: like header h: like header
--l_recognized: BOOLEAN
l_messages: HTTP_STATUS_CODE_MESSAGES l_messages: HTTP_STATUS_CODE_MESSAGES
do do
create l_messages create l_messages
h := header h := header
-- To be considered later if
--l_recognized := recognized_methods.has (request.request_method.as_upper) not attached recognized_methods as l_recognized_methods
--if l_recognized then or else l_recognized_methods.has (request.request_method.as_upper)
then
res.set_status_code (l_messages.method_not_allowed) res.set_status_code (l_messages.method_not_allowed)
--else else
-- res.set_status_code (l_messages.not_implemented) res.set_status_code (l_messages.not_implemented)
--end end
if attached suggested_methods as lst and then not lst.is_empty then if attached suggested_methods as lst and then not lst.is_empty then
h.put_allow (lst) h.put_allow (lst)
@@ -264,23 +279,23 @@ feature {WSF_RESPONSE} -- Output
feature {NONE} -- Implementation feature {NONE} -- Implementation
-- To be discussed later... -- To be discussed later...
--recognized_methods: WSF_REQUEST_METHODS default_recognized_methods: WSF_REQUEST_METHODS
-- All methods defined in HTTP/1.1 specification -- All methods defined in HTTP/1.1 specification
--| Should this include CONNECT? It probably shouldn't be recognized by an origin server, --| Should this include CONNECT? It probably shouldn't be recognized by an origin server,
--| We will need a way to extend this for additional methods that the server implements. E.g. PATCH. --| We will need a way to extend this for additional methods that the server implements. E.g. PATCH.
-- do do
-- create Result.make_from_iterable (<< create Result.make_from_iterable (<<
-- {HTTP_REQUEST_METHODS}.method_head, {HTTP_REQUEST_METHODS}.method_head,
-- {HTTP_REQUEST_METHODS}.method_get, {HTTP_REQUEST_METHODS}.method_get,
-- {HTTP_REQUEST_METHODS}.method_trace, {HTTP_REQUEST_METHODS}.method_trace,
-- {HTTP_REQUEST_METHODS}.method_options, {HTTP_REQUEST_METHODS}.method_options,
-- {HTTP_REQUEST_METHODS}.method_post, {HTTP_REQUEST_METHODS}.method_post,
-- {HTTP_REQUEST_METHODS}.method_put, {HTTP_REQUEST_METHODS}.method_put,
-- {HTTP_REQUEST_METHODS}.method_delete {HTTP_REQUEST_METHODS}.method_delete
-- >>) >>)
-- ensure ensure
-- recognized_methods_not_void: Result /= Void recognized_methods_not_void: Result /= Void
-- end end
html_error_code_text (a_messages: HTTP_STATUS_CODE_MESSAGES; a_recognized: BOOLEAN): READABLE_STRING_8 html_error_code_text (a_messages: HTTP_STATUS_CODE_MESSAGES; a_recognized: BOOLEAN): READABLE_STRING_8
-- Message for including in HTML error text according to `a_recognized' -- Message for including in HTML error text according to `a_recognized'