From 4612fdb5de07243135027715e108d8f732ae0a70 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Fri, 14 Dec 2012 15:51:12 +0100 Subject: [PATCH] Added Authorization and Allow Added is_empty and count --- .../network/protocol/http/src/http_header.e | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/library/network/protocol/http/src/http_header.e b/library/network/protocol/http/src/http_header.e index bb2d8d4b..e3a8956a 100644 --- a/library/network/protocol/http/src/http_header.e +++ b/library/network/protocol/http/src/http_header.e @@ -98,6 +98,18 @@ feature -- Recycle feature -- Access + count: INTEGER + -- Number of header items. + do + Result := headers.count + end + + is_empty: BOOLEAN + -- Is empty? + do + Result := count = 0 + end + headers: ARRAYED_LIST [READABLE_STRING_8] -- Header's lines @@ -377,6 +389,28 @@ feature -- Content-type helpers put_content_type_multipart_encrypted do put_content_type ({HTTP_MIME_TYPES}.multipart_encrypted) end put_content_type_application_x_www_form_encoded do put_content_type ({HTTP_MIME_TYPES}.application_x_www_form_encoded) end +feature -- Method related + + put_allow (a_methods: ITERABLE [READABLE_STRING_8]) + -- If `a_methods' is not empty, put `Allow' header with list `a_methods' of methods + local + s: STRING_8 + do + create s.make_empty + across + a_methods as c + loop + if not s.is_empty then + s.append_character (',') + end + s.append_character (' ') + s.append (c.item) + end + if not s.is_empty then + put_header_key_value ({HTTP_HEADER_NAMES}.header_allow, s) + end + end + feature -- Date put_date (s: READABLE_STRING_8) @@ -403,6 +437,14 @@ feature -- Date put_header_key_value ({HTTP_HEADER_NAMES}.header_last_modified, date_to_rfc1123_http_date_format (a_utc_date)) end +feature -- Authorization + + put_authorization (s: READABLE_STRING_8) + -- Put authorization `s' with "Authorization" header + do + put_header_key_value ({HTTP_HEADER_NAMES}.header_authorization, s) + end + feature -- Others put_expires (sec: INTEGER)