negotiate


Description:


[ Version ( since = "0.3" ) ]
public HandlerCallback negotiate (string header_name, string expectations, owned ForwardCallback<string> forward = forward, EqualFunc<string> match = ( EqualFunc < string >) str_case_equal)

Negotiate a HTTP header against a set of expectations.

The header is extracted as a quality list and a lookup is performed to see if the expected value is accepted by the user agent.

The expectation is selected such that it maximize the product of the quality and user agent preference. For equal values, user agent preferences are considered first, then expectations.

If the header is not provided in the request, it is assumed that the user agent consider any response as acceptable: the expectation with the highest quality will be forwarded.

If more than one expectations is supplied, the 'Vary' header with the negotiated header name will be appended to the response headers to indicate that the resource has been generated based on its value.

Parameters:

header_name

header to negotiate

expectations

expected values, possibly with a qvalue

forward

callback forwarding the best expectation

match

compare the user agent string against an expectation


Package: valum-0.3