Accept again detachable argument for HTTP_AUTHORIZATION.make (..) to avoid breaking existing code.

Note that HTTP_AUTHORIZATION.http_authorization is now detachable.
This commit is contained in:
2013-11-20 09:17:28 +01:00
parent 3d126b04a9
commit 2978ec33b7

View File

@@ -21,9 +21,9 @@ create
make_basic_auth, make_basic_auth,
make_custom_auth make_custom_auth
feature {NONE} -- Initialization feature -- Initialization
make (a_http_authorization: READABLE_STRING_8) make (a_http_authorization: detachable READABLE_STRING_8)
-- Initialize `Current'. -- Initialize `Current'.
local local
i: INTEGER i: INTEGER
@@ -31,39 +31,49 @@ feature {NONE} -- Initialization
u,p: READABLE_STRING_32 u,p: READABLE_STRING_32
utf: UTF_CONVERTER utf: UTF_CONVERTER
do do
create http_authorization.make_from_string (a_http_authorization) login := Void
create t.make_empty password := Void
type := t if a_http_authorization = Void then
if not a_http_authorization.is_empty then -- Default: Basic
i := 1 type := basic_auth_type
if a_http_authorization[i] = ' ' then http_authorization := Void
i := i + 1 else
end create http_authorization.make_from_string (a_http_authorization)
i := a_http_authorization.index_of (' ', i) create t.make_empty
if i > 0 then type := t
t.append (a_http_authorization.substring (1, i - 1)) if not a_http_authorization.is_empty then
t.right_adjust; t.left_adjust i := 1
if t.same_string (Basic_auth_type) then if a_http_authorization[i] = ' ' then
type := Basic_auth_type i := i + 1
s := (create {BASE64}).decoded_string (a_http_authorization.substring (i + 1, a_http_authorization.count)) end
i := s.index_of (':', 1) --| Let's assume ':' is forbidden in login ... i := a_http_authorization.index_of (' ', i)
if i > 0 then if i > 0 then
u := utf.utf_8_string_8_to_string_32 (s.substring (1, i - 1)) -- UTF_8 decoding to support unicode password t.append (a_http_authorization.substring (1, i - 1))
p := utf.utf_8_string_8_to_string_32 (s.substring (i + 1, s.count)) -- UTF_8 decoding to support unicode password t.right_adjust; t.left_adjust
login := u if t.same_string (Basic_auth_type) then
password := p type := Basic_auth_type
check s := (create {BASE64}).decoded_string (a_http_authorization.substring (i + 1, a_http_authorization.count))
(create {HTTP_AUTHORIZATION}.make_custom_auth (u, p, t)).http_authorization ~ http_authorization i := s.index_of (':', 1) --| Let's assume ':' is forbidden in login ...
if i > 0 then
u := utf.utf_8_string_8_to_string_32 (s.substring (1, i - 1)) -- UTF_8 decoding to support unicode password
p := utf.utf_8_string_8_to_string_32 (s.substring (i + 1, s.count)) -- UTF_8 decoding to support unicode password
login := u
password := p
check
(create {HTTP_AUTHORIZATION}.make_custom_auth (u, p, t)).http_authorization ~ http_authorization
end
end end
elseif t.same_string (Digest_auth_type) then
type := Digest_auth_type
to_implement ("HTTP Authorization %"digest%", not yet implemented")
else
to_implement ("HTTP Authorization %""+ t +"%", not yet implemented")
end end
elseif t.same_string (Digest_auth_type) then
type := Digest_auth_type
to_implement ("HTTP Authorization %"digest%", not yet implemented")
else
to_implement ("HTTP Authorization %""+ t +"%", not yet implemented")
end end
end end
end end
ensure
a_http_authorization /= Void implies http_authorization /= Void
end end
make_basic_auth (u: READABLE_STRING_32; p: READABLE_STRING_32) make_basic_auth (u: READABLE_STRING_32; p: READABLE_STRING_32)
@@ -101,7 +111,7 @@ feature {NONE} -- Initialization
feature -- Access feature -- Access
http_authorization: IMMUTABLE_STRING_8 http_authorization: detachable IMMUTABLE_STRING_8
type: READABLE_STRING_8 type: READABLE_STRING_8