From 754d3f670c8fbb533329239860be3e795d52c562 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Mon, 23 Jan 2012 18:20:25 +0100 Subject: [PATCH] Fixed issue with WSF_FILE_RESPONSE not setting the status code Added Last-Modified --- .../wsf/src/response/wsf_file_response.e | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/library/server/wsf/src/response/wsf_file_response.e b/library/server/wsf/src/response/wsf_file_response.e index a556a9ea..102391e9 100644 --- a/library/server/wsf/src/response/wsf_file_response.e +++ b/library/server/wsf/src/response/wsf_file_response.e @@ -46,7 +46,15 @@ feature {NONE} -- Initialization header := h h.put_content_type (content_type) + if attached file_last_modified as dt then + h.put_last_modified (dt) + end get_file_size + if file_size = 0 then + set_status_code ({HTTP_STATUS_CODE}.not_found) + else + set_status_code ({HTTP_STATUS_CODE}.ok) + end update_content_length end @@ -113,7 +121,7 @@ feature -- Element change set_status_code (c: like status_code) -- Set `status_code' to `c'. require - valid_status_code: status_code > 0 + valid_status_code: c > 0 do status_code := c ensure @@ -176,6 +184,17 @@ feature {NONE} -- Implementation: file system helper end end + file_last_modified: detachable DATE_TIME + -- Get `file_size' from file named `file_name' + local + f: RAW_FILE + do + create f.make (file_name) + if f.exists then + create Result.make_from_epoch (f.change_date) + end + end + file_extension (fn: STRING): STRING -- Extension of file `fn'. local