0

Is it acceptable for the QVALUE to be "1." or "0." in, say, the Accept-Language header? e.g. Accept-Language: en;q=1. or Accept: text/plain;q=0.

RFC7231 (and RFC2616) which specifies the ABNF for QVALUE as follows:

weight = OWS ";" OWS "q=" qvalue
qvalue = ( "0" [ "." 0*3DIGIT ] )
       / ( "1" [ "." 0*3("0") ] )

And specifies the "ABNF" as follows:

    <a>*<b>element

where <a> and <b> are optional decimal values, indicating at least <a> and at most <b> occurrences of the element.

This seems to imply that 0 or more digits after the decimal point are acceptable, suggesting that "1." and "0." are valid QVALUEs. However, my intuition is telling me that these are not valid floating point numbers.

I've searched high and low and I can't find any examples which demonstrate this.

4

1 回答 1

1

是的,ABNF 允许这样做。如果您在测试期间发现它不起作用,那么向 IETF HTTP 工作组报告会很有用(以便规范的未来版本可以警告不要使用它)。

于 2016-02-03T16:10:01.703 回答