Added to WSF_REQUEST
- raw_header_data: like meta_string_variable - read_input_data_into (buf: STRING) - is_content_type_accepted (a_content_type: READABLE_STRING_GENERAL): BOOLEAN Changed raw_input_data to return IMMUTABLE_STRING_8 Added WSF_METHOD_NOT_ALLOWED_RESPONSE Added WSF_TRACE_RESPONSE to respond TRACE request Now Not_found response return html content if the client accepts, other text/plain Implemented TRACE response, and Method not allowed as implementation of WSF_ROUTED_SERVICE.execute_default
This commit is contained in:
@@ -48,10 +48,23 @@ feature -- Execution
|
||||
execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Default procedure
|
||||
local
|
||||
msg: WSF_RESPONSE_MESSAGE
|
||||
not_found: WSF_NOT_FOUND_RESPONSE
|
||||
not_allowed: WSF_METHOD_NOT_ALLOWED_RESPONSE
|
||||
trace: WSF_TRACE_RESPONSE
|
||||
do
|
||||
create not_found.make (req)
|
||||
res.send (not_found)
|
||||
if req.is_request_method ({HTTP_REQUEST_METHODS}.method_trace) then
|
||||
create trace.make (req)
|
||||
msg := trace
|
||||
elseif attached router.allowed_methods_for_request (req) as mtds and then not mtds.is_empty then
|
||||
create not_allowed.make (req)
|
||||
not_allowed.set_suggested_methods (mtds)
|
||||
msg := not_allowed
|
||||
else
|
||||
create not_found.make (req)
|
||||
msg := not_found
|
||||
end
|
||||
res.send (msg)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
@@ -207,6 +207,31 @@ feature -- Status report
|
||||
end
|
||||
end
|
||||
|
||||
allowed_methods_for_request (req: WSF_REQUEST): WSF_ROUTER_METHODS
|
||||
-- Allowed methods for `req'
|
||||
local
|
||||
m: WSF_ROUTER_MAPPING
|
||||
l_rqsmethods: detachable WSF_ROUTER_METHODS
|
||||
do
|
||||
create Result
|
||||
|
||||
across
|
||||
mappings as c
|
||||
loop
|
||||
m := c.item.mapping
|
||||
if attached {WSF_ROUTING_HANDLER} m.handler as l_routing then
|
||||
l_rqsmethods := l_routing.router.allowed_methods_for_request (req)
|
||||
elseif m.is_mapping (req, Current) then
|
||||
l_rqsmethods := c.item.request_methods
|
||||
else
|
||||
l_rqsmethods := Void
|
||||
end
|
||||
if l_rqsmethods /= Void then
|
||||
Result := Result + l_rqsmethods
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Hook
|
||||
|
||||
execute_before (a_mapping: WSF_ROUTER_MAPPING)
|
||||
|
||||
Reference in New Issue
Block a user