From 4688ac86926f1663c12b7a2074bc1d0b74118277 Mon Sep 17 00:00:00 2001 From: Jake Leahy Date: Thu, 8 Dec 2022 21:33:00 +1100 Subject: [PATCH] use httpCore.parseHeader Saves reinventing the wheel --- src/nimhttpd.nim | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/nimhttpd.nim b/src/nimhttpd.nim index fc656a8..808bb6e 100644 --- a/src/nimhttpd.nim +++ b/src/nimhttpd.nim @@ -10,7 +10,7 @@ import uri, strscans -from httpcore import HttpMethod, HttpHeaders +from httpcore import HttpMethod, HttpHeaders, parseHeader import nimhttpdpkg/config @@ -227,12 +227,8 @@ when isMainModule: echo "Error: Invalid port: '", val, "'" echo "Running on default port instead." of "header", "H": - var key, value: string - if val.scanf("$+: $+", key, value): - headers[key] = value - else: - echo "Invalid header ", val, " passed. Should be in the form \"key: value\"" - quit QuitFailure + let (key, values) = parseHeader(val) + headers[key] = values else: discard of cmdArgument: -- 2.45.2