Comparisons on DAV:getcontenttype

Hi,

we recently came across the following issue.

DAV:getcontenttype is defined to have the value of the HTTP content-type
header. However, this header is defined as:

Content-Type   = "Content-Type" ":" media-type
media-type     = type "/" subtype *( ";" parameter )
       type           = token
       subtype        = token

This means, that queries against the content type can be quite tricky.

For instance,

	<eq xmlns="DAV:" casesensitive="0">
		<prop><getconttenttype/></prop>
		<literal>text/plain</literal>
	</eq>

will *not* match for resources where the HTTP content-type header would
contain a parameter such as "charset".

On the other hand,

	<like xmlns="DAV:" casesensitive="0">
		<prop><getconttenttype/></prop>
		<literal>text/plain;%</literal>
	</like>

will not match resource where no parameter is given. The naive fix:

	<like xmlns="DAV:" casesensitive="0">
		<prop><getconttenttype/></prop>
		<literal>text/plain%</literal>
	</like>

won't work either, because it would match "text/plain123" as well.

At this point, the only robust way to match the complete type and subtype,
but not any parameters, seems to be:

	<or xmlns="DAV:">
		<eq casesensitive="0">
			<prop><getconttenttype/></prop>
			<literal>text/plain</literal>
		</eq>
		<like casesensitive="0">
			<prop><getconttenttype/></prop>
			<literal>text/plain;%</literal>
		</like>
	</or>

and even this is fragile if a server decides not to support the casesentive
attribute.


Maybe we need a specific operator for queries on content types?

Julian

--
<green/>bytes GmbH -- http://www.greenbytes.de -- tel:+492512807760

Received on Friday, 17 January 2003 08:38:30 UTC