Using the new Content Negotiation library to implement WSF_REQUEST.is_content_type_accepted
This commit is contained in:
@@ -351,31 +351,9 @@ feature -- Helper
|
|||||||
-- Does client accepts content_type for the response?
|
-- Does client accepts content_type for the response?
|
||||||
--| Based on header "Accept:" that can be for instance
|
--| Based on header "Accept:" that can be for instance
|
||||||
--| text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
|
--| text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
|
||||||
local
|
|
||||||
i, j: INTEGER
|
|
||||||
do
|
do
|
||||||
if attached http_accept as l_accept then
|
if attached (create {SERVER_MEDIA_TYPE_NEGOTIATION}.make (a_content_type.as_string_8)).preference (<<a_content_type.as_string_8>>, http_accept) as l_variants then
|
||||||
i := l_accept.substring_index (a_content_type, 1)
|
Result := l_variants.is_acceptable
|
||||||
if i > 0 then
|
|
||||||
-- contains the text, now check if this is the exact text
|
|
||||||
if
|
|
||||||
i = 1 -- At the beginning of text
|
|
||||||
or else l_accept[i-1].is_space -- preceded by space
|
|
||||||
or else l_accept[i-1] = ',' -- preceded by other mime type
|
|
||||||
then
|
|
||||||
j := i + a_content_type.count
|
|
||||||
if l_accept.valid_index (j) then
|
|
||||||
Result := l_accept[j] = ',' -- followed by other mime type
|
|
||||||
or else l_accept[j] = ';' -- followed by quality ;q=...
|
|
||||||
or else l_accept[j].is_space -- followed by space
|
|
||||||
else -- end of text
|
|
||||||
Result := True
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Result := l_accept.has_substring (a_content_type)
|
|
||||||
else
|
|
||||||
Result := True
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user