diff options
author | Yardanico <tiberiumk12@gmail.com> | 2023-10-29 08:21:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-29 06:21:32 +0100 |
commit | 94ffc183323c859fc5a395404ac6035ae29cbc5a (patch) | |
tree | f7aba4cfcdb3e7b2c6de4f2e13957ffacd78e6bc /lib/pure/httpclient.nim | |
parent | fbc801d1d15aa2c5f12a3f3bc1e35aad185dafb1 (diff) | |
download | Nim-94ffc183323c859fc5a395404ac6035ae29cbc5a.tar.gz |
Fix #22862 - change the httpclient user-agent to be valid spec-wise (#22882)
Per https://datatracker.ietf.org/doc/html/rfc9110#name-user-agent a User-Agent is defined as follows: ``` User-Agent = product *( RWS ( product / comment ) ) ``` Where ``` product = token ["/" product-version] product-version = token ``` In this case, `token` is defined in RFC 7230 - https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6: ``` token = 1*tchar tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA ; any VCHAR, except delimiters ``` or, in the original RFC 2616 - https://datatracker.ietf.org/doc/html/rfc2616#section-2.2 (next page): ``` token = 1*<any CHAR except CTLs or separators> separators = "(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\" | <"> | "/" | "[" | "]" | "?" | "=" | "{" | "}" | SP | HT ``` which means that a `token` cannot have whitespace. Not sure if this should be in the breaking changelog section - theoretically, some clients might've relied on the old Nim user-agent? For some extra info, some other languages seem to have adopted the same hyphen user agent to specify the language + module, e.g.: - https://github.com/python/cpython/blob/main/Lib/urllib/request.py#L1679 (`Python-urllib/<version>`) Fixes #22862.
Diffstat (limited to 'lib/pure/httpclient.nim')
-rw-r--r-- | lib/pure/httpclient.nim | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim index 9444618db..d2bf925ba 100644 --- a/lib/pure/httpclient.nim +++ b/lib/pure/httpclient.nim @@ -359,7 +359,7 @@ type ## and `postContent` proc, ## when the server returns an error -const defUserAgent* = "Nim httpclient/" & NimVersion +const defUserAgent* = "Nim-httpclient/" & NimVersion proc httpError(msg: string) = var e: ref ProtocolError |