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:
@@ -28,7 +28,7 @@ feature {NONE} -- Initialization
|
||||
create suggested_items.make (0)
|
||||
end
|
||||
|
||||
feature -- Header
|
||||
feature -- Access
|
||||
|
||||
header: HTTP_HEADER
|
||||
-- Response' header
|
||||
@@ -48,8 +48,23 @@ feature -- Header
|
||||
-- Optional body
|
||||
-- Displayed as extra content
|
||||
|
||||
recognized_methods: detachable WSF_REQUEST_METHODS
|
||||
-- All methods recognized by the application
|
||||
|
||||
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' to `m'
|
||||
do
|
||||
@@ -82,18 +97,18 @@ feature {WSF_RESPONSE} -- Output
|
||||
l_text: detachable READABLE_STRING_GENERAL
|
||||
l_loc: detachable READABLE_STRING_8
|
||||
h: like header
|
||||
--l_recognized: BOOLEAN
|
||||
l_messages: HTTP_STATUS_CODE_MESSAGES
|
||||
do
|
||||
create l_messages
|
||||
h := header
|
||||
-- To be considered later
|
||||
--l_recognized := recognized_methods.has (request.request_method.as_upper)
|
||||
--if l_recognized then
|
||||
if
|
||||
not attached recognized_methods as l_recognized_methods
|
||||
or else l_recognized_methods.has (request.request_method.as_upper)
|
||||
then
|
||||
res.set_status_code (l_messages.method_not_allowed)
|
||||
--else
|
||||
-- res.set_status_code (l_messages.not_implemented)
|
||||
--end
|
||||
else
|
||||
res.set_status_code (l_messages.not_implemented)
|
||||
end
|
||||
|
||||
if attached suggested_methods as lst and then not lst.is_empty then
|
||||
h.put_allow (lst)
|
||||
@@ -264,23 +279,23 @@ feature {WSF_RESPONSE} -- Output
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
-- To be discussed later...
|
||||
--recognized_methods: WSF_REQUEST_METHODS
|
||||
default_recognized_methods: WSF_REQUEST_METHODS
|
||||
-- All methods defined in HTTP/1.1 specification
|
||||
--| 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.
|
||||
-- do
|
||||
-- create Result.make_from_iterable (<<
|
||||
-- {HTTP_REQUEST_METHODS}.method_head,
|
||||
-- {HTTP_REQUEST_METHODS}.method_get,
|
||||
-- {HTTP_REQUEST_METHODS}.method_trace,
|
||||
-- {HTTP_REQUEST_METHODS}.method_options,
|
||||
-- {HTTP_REQUEST_METHODS}.method_post,
|
||||
-- {HTTP_REQUEST_METHODS}.method_put,
|
||||
-- {HTTP_REQUEST_METHODS}.method_delete
|
||||
-- >>)
|
||||
-- ensure
|
||||
-- recognized_methods_not_void: Result /= Void
|
||||
-- end
|
||||
do
|
||||
create Result.make_from_iterable (<<
|
||||
{HTTP_REQUEST_METHODS}.method_head,
|
||||
{HTTP_REQUEST_METHODS}.method_get,
|
||||
{HTTP_REQUEST_METHODS}.method_trace,
|
||||
{HTTP_REQUEST_METHODS}.method_options,
|
||||
{HTTP_REQUEST_METHODS}.method_post,
|
||||
{HTTP_REQUEST_METHODS}.method_put,
|
||||
{HTTP_REQUEST_METHODS}.method_delete
|
||||
>>)
|
||||
ensure
|
||||
recognized_methods_not_void: Result /= Void
|
||||
end
|
||||
|
||||
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'
|
||||
|
||||
Reference in New Issue
Block a user