Minor optimization in HTTP_HEADER

This commit is contained in:
Jocelyn Fiat
2013-01-22 21:13:40 +01:00
parent d2767fd020
commit acd942b720

View File

@@ -203,21 +203,34 @@ feature -- Header change: general
add_header_key_value (k,v: READABLE_STRING_8) add_header_key_value (k,v: READABLE_STRING_8)
-- Add header `k:v', or replace existing header of same header name/key -- Add header `k:v', or replace existing header of same header name/key
local
s: STRING_8
do do
add_header (k + colon_space + v) create s.make (k.count + 2 + v.count)
s.append (k)
s.append (colon_space)
s.append (v)
add_header (s)
end end
put_header_key_value (k,v: READABLE_STRING_8) put_header_key_value (k,v: READABLE_STRING_8)
-- Add header `k:v', or replace existing header of same header name/key -- Add header `k:v', or replace existing header of same header name/key
local
s: STRING_8
do do
put_header (k + colon_space + v) create s.make (k.count + 2 + v.count)
s.append (k)
s.append (colon_space)
s.append (v)
put_header (s)
end end
put_header_key_values (k: READABLE_STRING_8; a_values: ITERABLE [READABLE_STRING_8]; a_separator: detachable STRING) put_header_key_values (k: READABLE_STRING_8; a_values: ITERABLE [READABLE_STRING_8]; a_separator: detachable READABLE_STRING_8)
-- Add header `k: a_values', or replace existing header of same header values/key. -- Add header `k: a_values', or replace existing header of same header values/key.
-- Use `comma_space' as default separator if `a_separator' is Void or empty. -- Use `comma_space' as default separator if `a_separator' is Void or empty.
local local
s, l_separator: STRING_8 s: STRING_8
l_separator: READABLE_STRING_8
do do
if a_separator /= Void and then not a_separator.is_empty then if a_separator /= Void and then not a_separator.is_empty then
l_separator := a_separator l_separator := a_separator
@@ -745,9 +758,20 @@ feature {NONE} -- Constants
str_binary: STRING = "binary" str_binary: STRING = "binary"
str_chunked: STRING = "chunked" str_chunked: STRING = "chunked"
colon_space: STRING = ": " colon_space: IMMUTABLE_STRING_8
semi_colon_space: STRING = "; " once
comma_space: STRING = ", " create Result.make_from_string (": ")
end
semi_colon_space: IMMUTABLE_STRING_8
once
create Result.make_from_string ("; ")
end
comma_space: IMMUTABLE_STRING_8
once
create Result.make_from_string (", ")
end
note note
copyright: "2011-2013, Jocelyn Fiat, Eiffel Software and others" copyright: "2011-2013, Jocelyn Fiat, Eiffel Software and others"