classafButter::QualityValues
sys::Obj afButter::QualityValues
Parses a Str
of HTTP qvalues as per HTTP 1.1 Spec / rfc2616-sec14.3. Provides some useful accessor methods; like `QualityValues.accepts` which returns true
only if the name exists AND has a qvalue greater than 0.0.
QualityValues("audio/*; q=0.2, audio/basic")
@see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3
- accepts
Returns
true
if the name was supplied in the header AND has a qvalue > 0.0This method matches against
*
wildcards.- clear
Void clear()
Clears the qvalues
- contains
Returns
true
ifname
was supplied in the header.This method matches against
*
wildcards.- fromStr
static new fromStr(Str? header := null, Bool checked := true)
Parses a HTTP header value into a
name:qvalue
map. Values are comma delimited with an optional q value.Throws
ParseErr
if the header Str is invalid.QualityValues("audio/*; q=0.2, audio/basic")
- get
Returns the qvalue associated with
name
. Defaults to0
ifname
is not mapped.Wildcards are not honoured but
name
is case-insensitive.- isEmpty
Bool isEmpty()
Returns
size() == 0
- qvalues
Returns a dup of the internal
name:qvalue
map.Use
get()
andset()
to modify qvalues.- set
@
Operator
This set(Str name, Float qval)Sets the given quality value.
Wildcards are not honoured but
name
is case-insensitive.- size
Int size()
Returns the number of values given in the header
- toStr
virtual override Str toStr()
Returns a joined-up Str of qvalues that may be set in a HTTP header. The names are sorted by qvalue. Example:
audio/*; q=0.2, audio/basic