From e21da4a591241c5ca1a4cc528dc28813ae4a1aff Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 7 Feb 2012 15:49:02 +0100 Subject: [PATCH] Improved the WSF_PAGE_RESPONSE to be more flexible and allow to change some values as expected. --- .../wsf/src/response/wsf_page_response.e | 34 +++++++++++++++++++ library/server/wsf/src/wsf_response.e | 14 ++------ 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/library/server/wsf/src/response/wsf_page_response.e b/library/server/wsf/src/response/wsf_page_response.e index 1fbe8be9..4806b74b 100644 --- a/library/server/wsf/src/response/wsf_page_response.e +++ b/library/server/wsf/src/response/wsf_page_response.e @@ -41,6 +41,40 @@ feature -- Header body: detachable STRING_8 +feature -- Element change + + put_header (a_status_code: INTEGER; a_headers: detachable ARRAY [TUPLE [key: READABLE_STRING_8; value: READABLE_STRING_8]]) + -- Send headers with status `a_status', and headers from `a_headers' + do + set_status_code (a_status_code) + if a_headers /= Void then + header.append_array (a_headers) + end + end + + set_status_code (c: like status_code) + do + status_code := c + end + + set_body (a_body: like body) + do + body := a_body + end + + put_string (a_string: READABLE_STRING_8) + -- Append `a_string' to `body' + local + l_body: like body + do + l_body := body + if l_body = Void then + create l_body.make (a_string.count) + set_body (l_body) + end + l_body.append (a_string) + end + feature -- Output send_to (res: WSF_RESPONSE) diff --git a/library/server/wsf/src/wsf_response.e b/library/server/wsf/src/wsf_response.e index 36c7915c..5fc4a69e 100644 --- a/library/server/wsf/src/wsf_response.e +++ b/library/server/wsf/src/wsf_response.e @@ -98,22 +98,12 @@ feature -- Header output operation header_not_committed: not header_committed local h: HTTP_HEADER - i,n: INTEGER do set_status_code (a_status_code) - create h.make if a_headers /= Void then - from - i := a_headers.lower - n := a_headers.upper - until - i > n - loop - h.put_header_key_value (a_headers[i].key, a_headers[i].value) - i := i + 1 - end + create h.make_from_array (a_headers) + wgi_response.put_header_text (h.string) end - wgi_response.put_header_text (h.string) ensure header_committed: header_committed status_set: status_is_set