Added some checks for custom erros being set.

This commit is contained in:
Colin Adams
2013-08-12 16:45:47 +01:00
parent 2ed362f5d3
commit b074570e99
2 changed files with 44 additions and 33 deletions

View File

@@ -23,34 +23,42 @@ feature {NONE} -- Implementation
-- "NEGOTIATED_ENCODING" -- "NEGOTIATED_ENCODING"
local local
l_dt: STRING l_dt: STRING
l_ok: BOOLEAN
do do
a_handler.delete (req) a_handler.delete (req)
if a_handler.includes_response_entity (req) then l_ok := a_handler.response_ok (req)
a_handler.ensure_content_available (req) if l_ok then
a_header.put_content_length (a_handler.content_length (req).as_integer_32)
-- we don't bother supporting chunked responses for DELETE.
else
a_header.put_content_length (0)
end
if attached req.request_time as l_time then
l_dt := (create {HTTP_DATE}.make_from_date_time (l_time)).rfc1123_string
a_header.put_header_key_value ({HTTP_HEADER_NAMES}.header_date, l_dt)
generate_cache_headers (req, a_handler, a_header, l_time)
end
if a_handler.delete_queued (req) then
res.set_status_code ({HTTP_STATUS_CODE}.accepted)
res.put_header_text (a_header.string)
res.put_string (a_handler.content (req))
elseif a_handler.deleted (req) then
if a_handler.includes_response_entity (req) then if a_handler.includes_response_entity (req) then
res.set_status_code ({HTTP_STATUS_CODE}.ok) a_handler.ensure_content_available (req)
l_ok := a_handler.response_ok (req)
if l_ok then
a_header.put_content_length (a_handler.content_length (req).as_integer_32)
end
-- we don't bother supporting chunked responses for DELETE.
else
a_header.put_content_length (0)
end
if attached req.request_time as l_time then
l_dt := (create {HTTP_DATE}.make_from_date_time (l_time)).rfc1123_string
a_header.put_header_key_value ({HTTP_HEADER_NAMES}.header_date, l_dt)
generate_cache_headers (req, a_handler, a_header, l_time)
end
if a_handler.delete_queued (req) then
res.set_status_code ({HTTP_STATUS_CODE}.accepted)
res.put_header_text (a_header.string) res.put_header_text (a_header.string)
res.put_string (a_handler.content (req)) res.put_string (a_handler.content (req))
else elseif a_handler.deleted (req) then
res.set_status_code ({HTTP_STATUS_CODE}.no_content) if a_handler.includes_response_entity (req) then
res.put_header_text (a_header.string) res.set_status_code ({HTTP_STATUS_CODE}.ok)
res.put_header_text (a_header.string)
res.put_string (a_handler.content (req))
else
res.set_status_code ({HTTP_STATUS_CODE}.no_content)
res.put_header_text (a_header.string)
end
end end
else end
if not l_ok then
write_error_response (req, res) write_error_response (req, res)
end end
end end

View File

@@ -26,18 +26,21 @@ feature {NONE} -- Implementation
l_dt: STRING l_dt: STRING
do do
a_handler.ensure_content_available (req) a_handler.ensure_content_available (req)
l_chunked := a_handler.is_chunking (req)
if l_chunked then
a_header.put_transfer_encoding_chunked
else
a_header.put_content_length (a_handler.content_length (req).as_integer_32)
end
if attached req.request_time as l_time then
l_dt := (create {HTTP_DATE}.make_from_date_time (l_time)).rfc1123_string
a_header.put_header_key_value ({HTTP_HEADER_NAMES}.header_date, l_dt)
generate_cache_headers (req, a_handler, a_header, l_time)
end
l_ok := a_handler.response_ok (req) l_ok := a_handler.response_ok (req)
if l_ok then
l_chunked := a_handler.is_chunking (req)
if l_chunked then
a_header.put_transfer_encoding_chunked
else
a_header.put_content_length (a_handler.content_length (req).as_integer_32)
end
if attached req.request_time as l_time then
l_dt := (create {HTTP_DATE}.make_from_date_time (l_time)).rfc1123_string
a_header.put_header_key_value ({HTTP_HEADER_NAMES}.header_date, l_dt)
generate_cache_headers (req, a_handler, a_header, l_time)
end
l_ok := a_handler.response_ok (req)
end
if l_ok then if l_ok then
res.set_status_code ({HTTP_STATUS_CODE}.ok) res.set_status_code ({HTTP_STATUS_CODE}.ok)
else else