summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authoralaviss <alaviss@users.noreply.github.com>2020-03-19 08:07:44 +0000
committerGitHub <noreply@github.com>2020-03-19 09:07:44 +0100
commitb33335d7fd467fbf40ae8fcb5417f6a3c659e8dc (patch)
tree45eba297d47a27560234034beba3f5483d14c39b /lib
parentc74cee4e6a86f2906136c27eb41972667e7c0faa (diff)
downloadNim-b33335d7fd467fbf40ae8fcb5417f6a3c659e8dc.tar.gz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/httpcore.nim9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/pure/httpcore.nim b/lib/pure/httpcore.nim
index 8c679c017..8916aa17d 100644
--- a/lib/pure/httpcore.nim
+++ b/lib/pure/httpcore.nim
@@ -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 =