Using the new Content Negotiation library to implement WSF_REQUEST.is_content_type_accepted

This commit is contained in:
2013-10-18 20:46:08 +02:00
parent 58dc2ec792
commit cf01756c1c

View File

@@ -351,31 +351,9 @@ feature -- Helper
-- Does client accepts content_type for the response?
--| Based on header "Accept:" that can be for instance
--| text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
local
i, j: INTEGER
do
if attached http_accept as l_accept then
i := l_accept.substring_index (a_content_type, 1)
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
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
Result := l_variants.is_acceptable
end
end