all repos — nimhttpd @ e4b24e1f9b48ba53748d4abd8d6b7478ecab1512

A useful static file web server.

use httpCore.parseHeader

Saves reinventing the wheel
Jake Leahy jake@leahy.dev
Thu, 08 Dec 2022 21:33:00 +1100
commit

e4b24e1f9b48ba53748d4abd8d6b7478ecab1512

parent

49edff091c899834d067b77f06b4c9ebd6c048cd

1 files changed, 3 insertions(+), 7 deletions(-)

jump to
M src/nimhttpd.nimsrc/nimhttpd.nim

@@ -10,7 +10,7 @@ times,

uri, strscans -from httpcore import HttpMethod, HttpHeaders +from httpcore import HttpMethod, HttpHeaders, parseHeader import nimhttpdpkg/config

@@ -227,12 +227,8 @@ else:

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: