w3c / ldp-testsuite

(UNMAINTAINED) Tests for Linked Data Platform (LDP)
Other
22 stars 29 forks source link

Allow Preference-Applied header check to include characters before or after the substring #173

Closed cbeer closed 10 years ago

cbeer commented 10 years ago

Without this change, a response including other data won't match, e.g.:

Preference-Applied: return=representation; include="http://www.w3.org/ns/ldp#PreferMembership http://www.w3.org/ns/ldp#PreferContainment"
spadgett commented 10 years ago

Per RFC 7240, parameters aren't included in the Preference-Applied response header.

The syntax of the Preference-Applied header differs from that of the Prefer
header in that parameters are not included.

Here is the ABNF grammar.

Preference-Applied = "Preference-Applied" ":" 1#applied-pref
applied-pref = token [ BWS "=" BWS word ]

A server could return more than one applied preference, which the regex won't match. For instance,

Preference-Applied: return=representation, foo=bar

The request from the test suite only has one preference in the Prefer header, however, so there should only be one applied preference in the response.

Having said that, I'm not sure the existing regex in the test suite is correct, either. It should probably be something more like

^return\s*=\s*"?representation"?$
cbeer commented 10 years ago

Ah, thanks for the link to the RFC. I was looking at an older draft. I'll take a look and update this pull request if the regex needs an update.