本文介绍了C#,HTTPClient-IfMatch格式要求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将.Net 4.5中的,则可以出现。

The tag is required to be an entity-tag as defined in section 3.11 of the HTTP specification, which in turn defines it as a quoted-string (see section 2.2 of the HTTP specification), optionally preceded by W/ to indicate a 'weak' tag. Roughly speaking, this means it can be pretty much any text at all but it has to be enclosed in double quotes. (If present, the W/ prefix comes before the opening quote.) The text within quotes can be anything except control characters or ". (And a " is allowed to appear if preceded by a \).

如果HTTP服务器报告ETag为 3-789d4d2b33bf4505f8f23fd4a1025a4e ,然后违反了规范。确实应该类似于 3-789d4d2b33bf4505f8f23fd4a1025a4e 。

If an HTTP server reports an ETag as 3-789d4d2b33bf4505f8f23fd4a1025a4e then it's violating the spec. It should really be something like "3-789d4d2b33bf4505f8f23fd4a1025a4e".

实体标签缺少引号。显然, HttpClient 在执行规则时有点不寻常,如果您必须处理违反规则的服务器,则它会显得有些麻烦。

That said, it seems to be quite common for entity tags to be missing the quotes. Apparently HttpClient is slightly unusual in enforcing the rules, making it slightly cumbersome if you're having to deal with a server that breaks the rules.

请注意,规范中存在错误。已发布的HTTP 1.1规范允许带引号的字符串以反斜杠结尾,例如 foo\ 或什至 \ 。但是,这不是本意。这样做的目的是,反斜杠将始终跟在另一个字符之后,并以在结束引号之前不加 \ 来区分,这是后两个示例所违反的。请参见。它已在下一版HTTP 1.1规范(HTTP bis,它似乎是Web标准的方式,将于现在的任何十年发布)的当前草案中得到修复。因此,尽管今天这两个字符串在技术上是合法的,但实现者最好避免这种情况。

Note that there's a bug in the spec. The published HTTP 1.1 spec allows quoted strings to end in a backslash, e.g., "foo\" or even just "\". However, this was not the intention. The intention was that a backslash would always be followed by another character, and that the closing quote would be distinguished by not being preceded by a \, something those last two examples violate. See this bug report. It has been fixed in the current draft of the next version of the HTTP 1.1 spec (HTTP bis, which, as seems to be the way with web standards, is due to be published any decade now). So although those two strings are technically legal today, implementors would be wise to avoid that sort of thing.

这篇关于C#,HTTPClient-IfMatch格式要求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 20:07