Addition to "http" library, separated constants into
- HTTP_MIME_TYPES - HTTP_HEADER_NAMES - HTTP_REQUEST_METHODS - HTTP_STATUS_CODE (already exists) Do not set the "Status" header when using WGI_RESPONSE_BUFFER.write_header (...) Cosmetic
This commit is contained in:
@@ -15,21 +15,21 @@ feature -- Execute template
|
||||
m: READABLE_STRING_8
|
||||
do
|
||||
m := req.request_method.as_upper
|
||||
if m.same_string ("GET") then
|
||||
if m.same_string ({HTTP_REQUEST_METHODS}.method_get) then
|
||||
execute_get (ctx, req, res)
|
||||
elseif m.same_string ("PUT") then
|
||||
elseif m.same_string ({HTTP_REQUEST_METHODS}.method_put) then
|
||||
execute_put (ctx, req, res)
|
||||
elseif m.same_string ("DELETE") then
|
||||
elseif m.same_string ({HTTP_REQUEST_METHODS}.method_delete) then
|
||||
execute_delete (ctx, req, res)
|
||||
elseif m.same_string ("POST") then
|
||||
elseif m.same_string ({HTTP_REQUEST_METHODS}.method_post) then
|
||||
execute_post (ctx, req, res)
|
||||
elseif m.same_string ("TRACE") then
|
||||
elseif m.same_string ({HTTP_REQUEST_METHODS}.method_trace) then
|
||||
execute_trace (ctx, req, res)
|
||||
elseif m.same_string ("OPTIONS") then
|
||||
elseif m.same_string ({HTTP_REQUEST_METHODS}.method_options) then
|
||||
execute_options (ctx, req, res)
|
||||
elseif m.same_string ("HEAD") then
|
||||
elseif m.same_string ({HTTP_REQUEST_METHODS}.method_head) then
|
||||
execute_head (ctx, req, res)
|
||||
elseif m.same_string ("CONNECT") then
|
||||
elseif m.same_string ({HTTP_REQUEST_METHODS}.method_connect) then
|
||||
execute_connect (ctx, req, res)
|
||||
else
|
||||
--| Eventually handle other methods...
|
||||
|
||||
@@ -79,7 +79,7 @@ feature -- Helper
|
||||
end
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.method_not_allowed)
|
||||
res.write_header ({HTTP_STATUS_CODE}.method_not_allowed, <<
|
||||
["Content-Type", {HTTP_CONSTANTS}.plain_text],
|
||||
["Content-Type", {HTTP_MIME_TYPES}.text_plain],
|
||||
["Allow", s]
|
||||
>>)
|
||||
res.write_string ("Unsupported request method, Allow: " + s + "%N")
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {REQUEST_HANDLER_CONTEXT}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -56,15 +55,15 @@ feature -- Query
|
||||
-- `a_content_type' converted into a request format name
|
||||
do
|
||||
if a_content_type /= Void then
|
||||
if a_content_type.same_string ({HTTP_CONSTANTS}.json_text) then
|
||||
if a_content_type.same_string ({HTTP_MIME_TYPES}.text_json) then
|
||||
Result := {HTTP_FORMAT_CONSTANTS}.json_name
|
||||
elseif a_content_type.same_string ({HTTP_CONSTANTS}.json_app) then
|
||||
elseif a_content_type.same_string ({HTTP_MIME_TYPES}.application_json) then
|
||||
Result := {HTTP_FORMAT_CONSTANTS}.json_name
|
||||
elseif a_content_type.same_string ({HTTP_CONSTANTS}.xml_text) then
|
||||
elseif a_content_type.same_string ({HTTP_MIME_TYPES}.text_xml) then
|
||||
Result := {HTTP_FORMAT_CONSTANTS}.xml_name
|
||||
elseif a_content_type.same_string ({HTTP_CONSTANTS}.html_text) then
|
||||
elseif a_content_type.same_string ({HTTP_MIME_TYPES}.text_html) then
|
||||
Result := {HTTP_FORMAT_CONSTANTS}.html_name
|
||||
elseif a_content_type.same_string ({HTTP_CONSTANTS}.plain_text) then
|
||||
elseif a_content_type.same_string ({HTTP_MIME_TYPES}.text_plain) then
|
||||
Result := {HTTP_FORMAT_CONSTANTS}.text_name
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user