Added process_transfer to implement process_file. This way, it is easier to redefine the transfert implementation, or the process_file directly, if needed.

This commit is contained in:
2016-01-18 17:05:35 +01:00
parent 1a4db1d7c6
commit 2ca87d53b8

View File

@@ -339,6 +339,20 @@ feature -- Execution
end end
process_file (f: FILE; req: WSF_REQUEST; res: WSF_RESPONSE) process_file (f: FILE; req: WSF_REQUEST; res: WSF_RESPONSE)
do
if
attached req.meta_string_variable ("HTTP_IF_MODIFIED_SINCE") as s_if_modified_since and then
attached http_date_format_to_date (s_if_modified_since) as l_if_modified_since_date and then
attached file_date (f) as f_date and then
f_date <= l_if_modified_since_date
then
process_not_modified (f_date, req, res)
else
process_transfert (f, req, res)
end
end
process_transfert (f: FILE; req: WSF_REQUEST; res: WSF_RESPONSE)
local local
ext: READABLE_STRING_32 ext: READABLE_STRING_32
ct: detachable READABLE_STRING_8 ct: detachable READABLE_STRING_8
@@ -350,14 +364,6 @@ feature -- Execution
if ct = Void then if ct = Void then
ct := {HTTP_MIME_TYPES}.application_force_download ct := {HTTP_MIME_TYPES}.application_force_download
end end
if
attached req.meta_string_variable ("HTTP_IF_MODIFIED_SINCE") as s_if_modified_since and then
attached http_date_format_to_date (s_if_modified_since) as l_if_modified_since_date and then
attached file_date (f) as f_date and then
f_date <= l_if_modified_since_date
then
process_not_modified (f_date, req, res)
else
create fres.make_with_content_type (ct, f.path.name) create fres.make_with_content_type (ct, f.path.name)
fres.set_status_code ({HTTP_STATUS_CODE}.ok) fres.set_status_code ({HTTP_STATUS_CODE}.ok)
@@ -374,7 +380,6 @@ feature -- Execution
fres.set_answer_head_request_method (req.request_method.same_string ({HTTP_REQUEST_METHODS}.method_head)) fres.set_answer_head_request_method (req.request_method.same_string ({HTTP_REQUEST_METHODS}.method_head))
res.send (fres) res.send (fres)
end end
end
process_not_modified (a_utc_date: detachable DATE_TIME; req: WSF_REQUEST; res: WSF_RESPONSE) process_not_modified (a_utc_date: detachable DATE_TIME; req: WSF_REQUEST; res: WSF_RESPONSE)
local local