From a9e2dc11355eb4d3b194f71a57f9221d91536597 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Fri, 7 Oct 2011 15:39:04 +0200 Subject: [PATCH] Added the possibility to specify the supported content types Added FIXME --- .../src/misc/request_resource_handler_helper.e | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/library/server/request/router/src/misc/request_resource_handler_helper.e b/library/server/request/router/src/misc/request_resource_handler_helper.e index 94c26d63..80c497d9 100644 --- a/library/server/request/router/src/misc/request_resource_handler_helper.e +++ b/library/server/request/router/src/misc/request_resource_handler_helper.e @@ -157,13 +157,20 @@ feature -- Method Extension Method feature -- Handle responses + supported_content_types: detachable ARRAY [READABLE_STRING_8] + -- Supported content types + -- Can be redefined + do + Result := Void + end + handle_bad_request_response (a_description:STRING; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER ) local h : EWF_HEADER do create h.make h.put_status ({HTTP_STATUS_CODE}.bad_request) - if attached ctx.request_content_type (Void) as l_content_type then + if attached ctx.request_content_type (supported_content_types) as l_content_type then h.put_content_type (l_content_type) else h.put_content_type ("*/*") @@ -181,10 +188,12 @@ feature -- Handle responses do create h.make h.put_status ({HTTP_STATUS_CODE}.internal_server_error) - if attached ctx.request_content_type (Void) as l_content_type then + if attached ctx.request_content_type (supported_content_types) as l_content_type then h.put_content_type (l_content_type) else h.put_content_type ("*/*") + --| FIXME: I guess it should be plain/text , + --| */* sounds more for Accept header in request end h.put_content_length (a_description.count) h.put_current_date @@ -199,7 +208,7 @@ feature -- Handle responses do create h.make h.put_status ({HTTP_STATUS_CODE}.not_implemented) - if attached ctx.request_content_type (Void) as l_content_type then + if attached ctx.request_content_type (supported_content_types) as l_content_type then h.put_content_type (l_content_type) else h.put_content_type ("*/*") @@ -217,7 +226,7 @@ feature -- Handle responses do create h.make h.put_status ({HTTP_STATUS_CODE}.not_found) - if attached ctx.request_content_type (Void) as l_content_type then + if attached ctx.request_content_type (supported_content_types) as l_content_type then h.put_content_type (l_content_type) else h.put_content_type ("*/*")