httpcore: deprecate ==(string, HttpCode) (#13682)
According to [RFC7230], the reason phrase attached to the status line is optional and clients should not rely on it. This in turn causes the proc to be practically useless, as clients should only inspect the return code. Ref #13680. [RFC7230]: https://tools.ietf.org/html/rfc7230#section-3.1.2
This commit is contained in:
parent
c74cee4e6a
commit
b33335d7fd
2 changed files with 11 additions and 1 deletions
|
|
@ -290,7 +290,14 @@ proc `$`*(code: HttpCode): string =
|
|||
|
||||
proc `==`*(a, b: HttpCode): bool {.borrow.}
|
||||
|
||||
proc `==`*(rawCode: string, code: HttpCode): bool =
|
||||
proc `==`*(rawCode: string, code: HttpCode): bool
|
||||
{.deprecated: "Deprecated since v1.2; use rawCode == $code instead".} =
|
||||
## Compare the string form of the status code with a HttpCode
|
||||
##
|
||||
## **Note**: According to HTTP/1.1 specification, the reason phrase is
|
||||
## optional and should be ignored by the client, making this
|
||||
## proc only suitable for comparing the ``HttpCode`` against the
|
||||
## string form of itself.
|
||||
return cmpIgnoreCase(rawCode, $code) == 0
|
||||
|
||||
proc is2xx*(code: HttpCode): bool =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue